Skip to content
This repository has been archived by the owner on Jun 26, 2021. It is now read-only.

EMF model with DocumentRoot is not getting resolve #98

Open
chakraborty-slx opened this issue May 30, 2017 · 1 comment
Open

EMF model with DocumentRoot is not getting resolve #98

chakraborty-slx opened this issue May 30, 2017 · 1 comment

Comments

@chakraborty-slx
Copy link

chakraborty-slx commented May 30, 2017

Using version v1.0 instead of v0.15

A common EMF model with DocumentRoot and child element inside in it, is not resolved properly.



		final ObjectMapper mapper = new ObjectMapper();
		EMFModule module = new EMFModule();
		module.configure(EMFModule.Feature.OPTION_USE_ID, true);
		module.configure(EMFModule.Feature.OPTION_SERIALIZE_TYPE, false);
		mapper.registerModule(module);

		final ResourceSetImpl jsonResourceSet = new ResourceSetImpl();
		jsonResourceSet.getPackageRegistry().put(CallgraphPackage.eNS_URI, CallgraphPackage.eINSTANCE);

		jsonResourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", new JsonResourceFactory(mapper));

		final Resource resource = jsonResourceSet.createResource(URI.createURI("VIRTUAL_JSON-URI"));

		DocumentRoot dr = CallgraphFactoryImpl.eINSTANCE.createDocumentRoot();
		CallGraph cg = CallgraphFactoryImpl.eINSTANCE.createCallGraph();
		Function func1 = CallgraphFactoryImpl.eINSTANCE.createFunction();
		Function func2 = CallgraphFactoryImpl.eINSTANCE.createFunction();
		Function func3 = CallgraphFactoryImpl.eINSTANCE.createFunction();

		func1.setName("func1");
		func2.setName("func2");
		Call call1 = CallgraphFactoryImpl.eINSTANCE.createCall();
		call1.setCallee(func1);
		call1.setCaller(func2);
		cg.getCall().add(call1);
		cg.getFunction().add(func1);
		cg.getFunction().add(func2);
		cg.getFunction().add(func3);
		dr.setCallGraph(cg);

		((JsonResource) resource).setID(cg, "1");
		resource.getContents().add(dr);

		try {

			JsonNode result = mapper.valueToTree(resource);

			String jsonString = mapper.writeValueAsString(resource);
			System.out.println(jsonString);
		} catch (JsonProcessingException e1) {
			e1.printStackTrace();
		}

	

Output is only

{"@id":"_Pg7e0EVYEeeDcbTRWgbgUA"}

@kvcheban
Copy link

kvcheban commented Mar 4, 2021

Same issue using version 1.2.0 instead of 0.13.0.
Could someone provide a fix? Or maybe help with finding a fix?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants