{"action":"created","issue":{"url":"https://api.github.com/repos/xebia-france/selma/issues/74","repository_url":"https://api.github.com/repos/xebia-france/selma","labels_url":"https://api.github.com/repos/xebia-france/selma/issues/74/labels{/name}","comments_url":"https://api.github.com/repos/xebia-france/selma/issues/74/comments","events_url":"https://api.github.com/repos/xebia-france/selma/issues/74/events","html_url":"https://github.com/xebia-france/selma/issues/74","id":136441072,"number":74,"title":"Map multiplie fields into one","user":{"login":"denouche","id":3081451,"avatar_url":"https://avatars.githubusercontent.com/u/3081451?v=3","gravatar_id":"","url":"https://api.github.com/users/denouche","html_url":"https://github.com/denouche","followers_url":"https://api.github.com/users/denouche/followers","following_url":"https://api.github.com/users/denouche/following{/other_user}","gists_url":"https://api.github.com/users/denouche/gists{/gist_id}","starred_url":"https://api.github.com/users/denouche/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/denouche/subscriptions","organizations_url":"https://api.github.com/users/denouche/orgs","repos_url":"https://api.github.com/users/denouche/repos","events_url":"https://api.github.com/users/denouche/events{/privacy}","received_events_url":"https://api.github.com/users/denouche/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-02-25T16:39:37Z","updated_at":"2016-02-28T22:35:32Z","closed_at":null,"body":"Hi,\r\n\r\nI have a problem and I cannot figure out how to use Selma to handle it.\r\n\r\nMy beans are the following:\r\n```java\r\npublic class Destination {\r\n  private Long id;\r\n  private String lang;\r\n  private String title;\r\n  private Set<String> otherLabels;\r\n\r\n  public Destination(String lang) {\r\n    this.lang = lang;\r\n  }\r\n}\r\n```\r\n\r\n```java\r\npublic class Source {\r\n  private Long id;\r\n  private Set<Label> title;\r\n  private Set<Label> otherLabels;\r\n}\r\npublic class Label {\r\n  private String lang;\r\n  private String value;\r\n}\r\n```\r\n\r\nI would like to be able to map the `source.labels` to `destination.label` according to the `destination.lang`, to finally call something like:\r\n`mapper.updateDest(source, new Destination(lang))`\r\n\r\nSame thing with `otherLabels` field.\r\n\r\nThe problem is that Selma does not allow (to my to knowledge) to map an attribute to another being aware of the whole bean, to access other attributes while mapping a field.\r\n\r\nMaybe the answer is to be able to have a custom mapper like:\r\n```java\r\n  public String asString(Set<Label> in, Source source, Destination destination) {\r\n    // If I have access here to destination and source I call handle my case and other cases which need to access to Sources properties to realize the mapping\r\n  }\r\n```\r\nMaybe there is another easier answer to my question?\r\n\r\nThanks you in advance\r\n"},"comment":{"url":"https://api.github.com/repos/xebia-france/selma/issues/comments/189959110","html_url":"https://github.com/xebia-france/selma/issues/74#issuecomment-189959110","issue_url":"https://api.github.com/repos/xebia-france/selma/issues/74","id":189959110,"user":{"login":"slemesle","id":599375,"avatar_url":"https://avatars.githubusercontent.com/u/599375?v=3","gravatar_id":"","url":"https://api.github.com/users/slemesle","html_url":"https://github.com/slemesle","followers_url":"https://api.github.com/users/slemesle/followers","following_url":"https://api.github.com/users/slemesle/following{/other_user}","gists_url":"https://api.github.com/users/slemesle/gists{/gist_id}","starred_url":"https://api.github.com/users/slemesle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slemesle/subscriptions","organizations_url":"https://api.github.com/users/slemesle/orgs","repos_url":"https://api.github.com/users/slemesle/repos","events_url":"https://api.github.com/users/slemesle/events{/privacy}","received_events_url":"https://api.github.com/users/slemesle/received_events","type":"User","site_admin":false},"created_at":"2016-02-28T22:35:32Z","updated_at":"2016-02-28T22:35:32Z","body":"Hi,\r\n\r\nfor this kind of use, I would recommend handling the business logic on your own. \r\n\r\nYou can use a mapper interceptor to have access to source and destination. \r\n\r\n```java\r\npublic class MapperInterceptor {\r\n    public void interceptSourceToDestination(Source source, Destination destination) {\r\n        // Do some processing here the destination is already mapped.\r\n    }\r\n}\r\n```\r\n\r\nThe custom mapper is also a good point, but I definitely thinks this kind of mapping should be handled using Selma. This looks like business logic and not stupid mapping :p. \r\nIf your beans are really those so it will take about 10 mins to implement the code needed by hand. \r\n\r\nSorry but I don't see any help in Selma for that. I'll rethink about it but I do not have better idea than this one.\r\n\r\n\r\n"}}