{"action":"opened","issue":{"url":"https://api.github.com/repos/ObeoNetwork/M2Doc/issues/81","repository_url":"https://api.github.com/repos/ObeoNetwork/M2Doc","labels_url":"https://api.github.com/repos/ObeoNetwork/M2Doc/issues/81/labels{/name}","comments_url":"https://api.github.com/repos/ObeoNetwork/M2Doc/issues/81/comments","events_url":"https://api.github.com/repos/ObeoNetwork/M2Doc/issues/81/events","html_url":"https://github.com/ObeoNetwork/M2Doc/issues/81","id":187350500,"number":81,"title":"\"m:diagam\" tag generates a “Not found Representation” failure with Sirius 4","user":{"login":"ohaegi","id":1122686,"avatar_url":"https://avatars.githubusercontent.com/u/1122686?v=3","gravatar_id":"","url":"https://api.github.com/users/ohaegi","html_url":"https://github.com/ohaegi","followers_url":"https://api.github.com/users/ohaegi/followers","following_url":"https://api.github.com/users/ohaegi/following{/other_user}","gists_url":"https://api.github.com/users/ohaegi/gists{/gist_id}","starred_url":"https://api.github.com/users/ohaegi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ohaegi/subscriptions","organizations_url":"https://api.github.com/users/ohaegi/orgs","repos_url":"https://api.github.com/users/ohaegi/repos","events_url":"https://api.github.com/users/ohaegi/events{/privacy}","received_events_url":"https://api.github.com/users/ohaegi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-11-04T14:41:14Z","updated_at":"2016-11-04T14:41:14Z","closed_at":null,"body":"The tag “m:diagram” generates a  a “Not found Representation” failure with Sirius 4\r\nFor example, if template contains : \r\n`m:diagram title:\"'LayerTestDiagram'”`\r\nthe generated document contains :\r\n`m:diagram title:\"A problem occured while creating image from an diagram provider : Representation with title 'LayerTestDiagram' not found`\r\n\r\n The methods “org.obeonetwork.m2doc.sirius.providers.SiriusDiagramByTitleProvider.getAssociatedRepresentationByName(String, Session)” and “org.obeonetwork.m2doc.sirius.providers.SiriusDiagramByDiagramDescriptionNameProvider.getAssociatedRepresentationByDiagramDescriptionAndName(EObject, String, Session)”  are not compatible with SIRIUS 4  because after this version representations are not anymore contained by a DView.\r\n\r\nWe must have 2 codes to ensure Sirius 4 compatibility : \r\n\r\nCode for before  Sirius 4 compatibility (like it is in master branch):\r\n\r\n`\r\nprivate DRepresentation getAssociatedRepresentationByName(String representationName, Session session) {\r\n        if (representationName != null) {\r\n            Collection<DRepresentation> representations = DialectManager.INSTANCE.getAllRepresentations(session);\r\n            // Filter representations to keep only those in a selected viewpoint\r\n            Collection<Viewpoint> selectedViewpoints = session.getSelectedViewpoints(false);\r\n\r\n            for (DRepresentation representation : representations) {\r\n\r\n                if (representationName.equals(representation.getName())\r\n                    && representation.eContainer() instanceof DView) {\r\n                    DView dView = (DView) representation.eContainer();\r\n                    Viewpoint vp = dView.getViewpoint();\r\n                    if (selectedViewpoints.contains(vp)) {\r\n                        return representation;\r\n                    }\r\n                }\r\n            }\r\n        }\r\n\r\n        return null;\r\n    }\r\n`\r\n\r\nCode for after  Sirius 4 compatibility : \r\n`\r\nprivate DRepresentation getAssociatedRepresentationByName(String representationName, Session session) {\r\n        if (representationName != null) {\r\n            Collection<DRepresentationDescriptor> repDescriptors = DialectManager.INSTANCE\r\n                    .getAllRepresentationDescriptors(session);\r\n\r\n            // Filter representations to keep only those in a selected viewpoint\r\n            Collection<Viewpoint> selectedViewpoints = session.getSelectedViewpoints(false);\r\n\r\n            for (DRepresentationDescriptor dRepresentationDescriptor : repDescriptors) {\r\n                if (representationName.equals(dRepresentationDescriptor.getName())\r\n                    && dRepresentationDescriptor.eContainer() instanceof DView) {\r\n                    DView dView = (DView) dRepresentationDescriptor.eContainer();\r\n                    Viewpoint vp = dView.getViewpoint();\r\n                    if (selectedViewpoints.contains(vp)) {\r\n                        return dRepresentationDescriptor.getRepresentation();\r\n                    }\r\n                }\r\n            }\r\n        }\r\n\r\n        return null;\r\n    }\r\n`"}}
{"actor":{"display_login":"ohaegi"}}