List of usage examples for com.fasterxml.jackson.core JsonParser skipChildren
public abstract JsonParser skipChildren() throws IOException, JsonParseException;
From source file:com.adobe.communities.ugc.migration.importer.UGCImportHelper.java
protected static void importTranslation(final JsonParser jsonParser, final Resource post) throws IOException { JsonToken token = jsonParser.getCurrentToken(); final Map<String, Object> properties = new HashMap<String, Object>(); if (token != JsonToken.START_OBJECT) { throw new IOException("expected a start object token, got " + token.asString()); }/*from ww w.j a v a 2s . c o m*/ properties.put("jcr:primaryType", "social:asiResource"); Resource translationFolder = null; token = jsonParser.nextToken(); while (token == JsonToken.FIELD_NAME) { token = jsonParser.nextToken(); //advance to the field value if (jsonParser.getCurrentName().equals((ContentTypeDefinitions.LABEL_TRANSLATIONS))) { if (null == translationFolder) { // begin by creating the translation folder resource translationFolder = post.getResourceResolver().create(post, "translation", properties); } //now check to see if any translations exist if (token == JsonToken.START_OBJECT) { token = jsonParser.nextToken(); if (token == JsonToken.FIELD_NAME) { while (token == JsonToken.FIELD_NAME) { // each new field represents another translation final Map<String, Object> translationProperties = new HashMap<String, Object>(); translationProperties.put("jcr:primaryType", "social:asiResource"); String languageLabel = jsonParser.getCurrentName(); token = jsonParser.nextToken(); if (token != JsonToken.START_OBJECT) { throw new IOException("expected a start object token for translation item, got " + token.asString()); } token = jsonParser.nextToken(); while (token != JsonToken.END_OBJECT) { jsonParser.nextToken(); //get next field value if (jsonParser.getCurrentName() .equals(ContentTypeDefinitions.LABEL_TIMESTAMP_FIELDS)) { jsonParser.nextToken(); // advance to first field name while (!jsonParser.getCurrentToken().equals(JsonToken.END_ARRAY)) { final String timestampLabel = jsonParser.getValueAsString(); if (translationProperties.containsKey(timestampLabel)) { final Calendar calendar = new GregorianCalendar(); calendar.setTimeInMillis(Long .parseLong((String) translationProperties.get(timestampLabel))); translationProperties.put(timestampLabel, calendar.getTime()); } jsonParser.nextToken(); } } else if (jsonParser.getCurrentName() .equals(ContentTypeDefinitions.LABEL_SUBNODES)) { jsonParser.skipChildren(); } else { translationProperties.put(jsonParser.getCurrentName(), URLDecoder.decode(jsonParser.getValueAsString(), "UTF-8")); } token = jsonParser.nextToken(); //get next field label } // add the language-specific translation under the translation folder resource Resource translation = post.getResourceResolver().create(post.getChild("translation"), languageLabel, translationProperties); if (null == translation) { throw new IOException("translation not actually imported"); } } jsonParser.nextToken(); //skip END_OBJECT token for translation } else if (token == JsonToken.END_OBJECT) { // no actual translation to import, so we're done here jsonParser.nextToken(); } } else { throw new IOException( "expected translations to be contained in an object, saw instead: " + token.asString()); } } else if (jsonParser.getCurrentName().equals("mtlanguage") || jsonParser.getCurrentName().equals("jcr:createdBy")) { properties.put(jsonParser.getCurrentName(), jsonParser.getValueAsString()); } else if (jsonParser.getCurrentName().equals("jcr:created")) { final Calendar calendar = new GregorianCalendar(); calendar.setTimeInMillis(jsonParser.getLongValue()); properties.put("jcr:created", calendar.getTime()); } token = jsonParser.nextToken(); } if (null == translationFolder && properties.containsKey("mtlanguage")) { // it's possible that no translations existed, so we need to make sure the translation resource (which // includes the original post's detected language) is created anyway post.getResourceResolver().create(post, "translation", properties); } }
From source file:com.adobe.communities.ugc.migration.importer.GenericUGCImporter.java
/** * Handle each of the importable types of ugc content * @param jsonParser - the parsing stream * @param resource - the parent resource of whatever it is we're importing (must already exist) * @throws ServletException// www . j av a2 s . c o m * @throws IOException */ protected void importFile(final JsonParser jsonParser, final Resource resource, final ResourceResolver resolver) throws ServletException, IOException { final UGCImportHelper importHelper = new UGCImportHelper(); JsonToken token1 = jsonParser.getCurrentToken(); importHelper.setSocialUtils(socialUtils); if (token1.equals(JsonToken.START_OBJECT)) { jsonParser.nextToken(); if (jsonParser.getCurrentName().equals(ContentTypeDefinitions.LABEL_CONTENT_TYPE)) { jsonParser.nextToken(); final String contentType = jsonParser.getValueAsString(); if (contentType.equals(ContentTypeDefinitions.LABEL_QNA_FORUM)) { importHelper.setQnaForumOperations(qnaForumOperations); } else if (contentType.equals(ContentTypeDefinitions.LABEL_FORUM)) { importHelper.setForumOperations(forumOperations); } else if (contentType.equals(ContentTypeDefinitions.LABEL_CALENDAR)) { importHelper.setCalendarOperations(calendarOperations); } else if (contentType.equals(ContentTypeDefinitions.LABEL_JOURNAL)) { importHelper.setJournalOperations(journalOperations); } else if (contentType.equals(ContentTypeDefinitions.LABEL_FILELIBRARY)) { importHelper.setFileLibraryOperations(fileLibraryOperations); } importHelper.setTallyService(tallyOperationsService); // (everything potentially needs tally) importHelper.setCommentOperations(commentOperations); // nearly anything can have comments on it jsonParser.nextToken(); // content if (jsonParser.getCurrentName().equals(ContentTypeDefinitions.LABEL_CONTENT)) { jsonParser.nextToken(); token1 = jsonParser.getCurrentToken(); if (token1.equals(JsonToken.START_OBJECT) || token1.equals(JsonToken.START_ARRAY)) { if (!resolver.isLive()) { throw new ServletException("Resolver is already closed"); } } else { throw new ServletException("Start object token not found for content"); } if (token1.equals(JsonToken.START_OBJECT)) { try { if (contentType.equals(ContentTypeDefinitions.LABEL_QNA_FORUM)) { importHelper.importQnaContent(jsonParser, resource, resolver); } else if (contentType.equals(ContentTypeDefinitions.LABEL_FORUM)) { importHelper.importForumContent(jsonParser, resource, resolver); } else if (contentType.equals(ContentTypeDefinitions.LABEL_COMMENTS)) { importHelper.importCommentsContent(jsonParser, resource, resolver); } else if (contentType.equals(ContentTypeDefinitions.LABEL_JOURNAL)) { importHelper.importJournalContent(jsonParser, resource, resolver); } else if (contentType.equals(ContentTypeDefinitions.LABEL_FILELIBRARY)) { importHelper.importFileLibrary(jsonParser, resource, resolver); } else { LOG.info("Unsupported content type: {}", contentType); jsonParser.skipChildren(); } jsonParser.nextToken(); } catch (final IOException e) { throw new ServletException(e); } jsonParser.nextToken(); // skip over END_OBJECT } else { try { if (contentType.equals(ContentTypeDefinitions.LABEL_CALENDAR)) { importHelper.importCalendarContent(jsonParser, resource, resolver); } else if (contentType.equals(ContentTypeDefinitions.LABEL_TALLY)) { importHelper.importTallyContent(jsonParser, resource, resolver); } else { LOG.info("Unsupported content type: {}", contentType); jsonParser.skipChildren(); } jsonParser.nextToken(); } catch (final IOException e) { throw new ServletException(e); } jsonParser.nextToken(); // skip over END_ARRAY } } else { throw new ServletException("Content not found"); } } else { throw new ServletException("No content type specified"); } } else { throw new ServletException("Invalid Json format"); } }
From source file:com.adobe.communities.ugc.migration.importer.ImportFileUploadServlet.java
/** * Handle each of the importable types of ugc content * @param jsonParser - the parsing stream * @param resource - the parent resource of whatever it is we're importing (must already exist) * @throws ServletException/*from w w w . j a v a 2 s .co m*/ * @throws IOException */ private void importFile(final JsonParser jsonParser, final Resource resource, final ResourceResolver resolver) throws ServletException, IOException { final UGCImportHelper importHelper = new UGCImportHelper(); JsonToken token1 = jsonParser.getCurrentToken(); if (token1.equals(JsonToken.START_OBJECT)) { jsonParser.nextToken(); if (jsonParser.getCurrentName().equals(ContentTypeDefinitions.LABEL_CONTENT_TYPE)) { jsonParser.nextToken(); final String contentType = jsonParser.getValueAsString(); if (contentType.equals(ContentTypeDefinitions.LABEL_QNA_FORUM)) { importHelper.setQnaForumOperations(qnaForumOperations); } else if (contentType.equals(ContentTypeDefinitions.LABEL_FORUM)) { importHelper.setForumOperations(forumOperations); } else if (contentType.equals(ContentTypeDefinitions.LABEL_COMMENTS)) { importHelper.setCommentOperations(commentOperations); } else if (contentType.equals(ContentTypeDefinitions.LABEL_CALENDAR)) { importHelper.setCalendarOperations(calendarOperations); } else if (contentType.equals(ContentTypeDefinitions.LABEL_JOURNAL)) { importHelper.setJournalOperations(journalOperations); } else if (contentType.equals(ContentTypeDefinitions.LABEL_TALLY)) { importHelper.setSocialUtils(socialUtils); } importHelper.setTallyService(tallyOperationsService); // (everything potentially needs tally) jsonParser.nextToken(); // content if (jsonParser.getCurrentName().equals(ContentTypeDefinitions.LABEL_CONTENT)) { jsonParser.nextToken(); token1 = jsonParser.getCurrentToken(); if (token1.equals(JsonToken.START_OBJECT) || token1.equals(JsonToken.START_ARRAY)) { if (!resolver.isLive()) { throw new ServletException("Resolver is already closed"); } } else { throw new ServletException("Start object token not found for content"); } if (token1.equals(JsonToken.START_OBJECT)) { try { if (contentType.equals(ContentTypeDefinitions.LABEL_QNA_FORUM)) { importHelper.importQnaContent(jsonParser, resource, resolver); } else if (contentType.equals(ContentTypeDefinitions.LABEL_FORUM)) { importHelper.importForumContent(jsonParser, resource, resolver); } else if (contentType.equals(ContentTypeDefinitions.LABEL_COMMENTS)) { importHelper.importCommentsContent(jsonParser, resource, resolver); } else if (contentType.equals(ContentTypeDefinitions.LABEL_JOURNAL)) { importHelper.importJournalContent(jsonParser, resource, resolver); } else { LOG.info("Unsupported content type: {}", contentType); jsonParser.skipChildren(); } jsonParser.nextToken(); } catch (final IOException e) { throw new ServletException(e); } jsonParser.nextToken(); // skip over END_OBJECT } else { try { if (contentType.equals(ContentTypeDefinitions.LABEL_CALENDAR)) { importHelper.importCalendarContent(jsonParser, resource); } else if (contentType.equals(ContentTypeDefinitions.LABEL_TALLY)) { importHelper.importTallyContent(jsonParser, resource); } else { LOG.info("Unsupported content type: {}", contentType); jsonParser.skipChildren(); } jsonParser.nextToken(); } catch (final IOException e) { throw new ServletException(e); } jsonParser.nextToken(); // skip over END_ARRAY } } else { throw new ServletException("Content not found"); } } else { throw new ServletException("No content type specified"); } } else { throw new ServletException("Invalid Json format"); } }
From source file:com.adobe.communities.ugc.migration.importer.UGCImportHelper.java
protected void extractTopic(final JsonParser jsonParser, final Resource resource, final ResourceResolver resolver, final CommentOperations operations) throws IOException, ServletException { if (jsonParser.getCurrentToken().equals(JsonToken.END_OBJECT)) { return; // replies could just be an empty object (i.e. "ugc:replies":{} ) in which case, do nothing }/*from w w w. j a v a 2 s . c o m*/ final Map<String, Object> properties = new HashMap<String, Object>(); properties.put("social:key", jsonParser.getCurrentName()); Resource post = null; jsonParser.nextToken(); if (jsonParser.getCurrentToken().equals(JsonToken.START_OBJECT)) { jsonParser.nextToken(); String author = null; List<DataSource> attachments = new ArrayList<DataSource>(); while (!jsonParser.getCurrentToken().equals(JsonToken.END_OBJECT)) { final String label = jsonParser.getCurrentName(); JsonToken token = jsonParser.nextToken(); if (jsonParser.getCurrentToken().isScalarValue()) { // either a string, boolean, or long value if (token.isNumeric()) { properties.put(label, jsonParser.getValueAsLong()); } else { final String value = jsonParser.getValueAsString(); if (value.equals("true") || value.equals("false")) { properties.put(label, jsonParser.getValueAsBoolean()); } else { final String decodedValue = URLDecoder.decode(value, "UTF-8"); if (label.equals("language")) { properties.put("mtlanguage", decodedValue); } else { properties.put(label, decodedValue); if (label.equals("userIdentifier")) { author = decodedValue; } else if (label.equals("jcr:description")) { properties.put("message", decodedValue); } } } } } else if (label.equals(ContentTypeDefinitions.LABEL_ATTACHMENTS)) { attachments = getAttachments(jsonParser); } else if (label.equals(ContentTypeDefinitions.LABEL_REPLIES) || label.equals(ContentTypeDefinitions.LABEL_TALLY) || label.equals(ContentTypeDefinitions.LABEL_TRANSLATION) || label.equals(ContentTypeDefinitions.LABEL_SUBNODES)) { // replies and sub-nodes ALWAYS come after all other properties and attachments have been listed, // so we can create the post now if we haven't already, and then dive in if (post == null) { try { post = createPost(resource, author, properties, attachments, resolver.adaptTo(Session.class), operations); resProvider = SocialResourceUtils.getSocialResource(post).getResourceProvider(); } catch (Exception e) { throw new ServletException(e.getMessage(), e); } } if (label.equals(ContentTypeDefinitions.LABEL_REPLIES)) { if (token.equals(JsonToken.START_OBJECT)) { jsonParser.nextToken(); while (!token.equals(JsonToken.END_OBJECT)) { extractTopic(jsonParser, post, resolver, operations); token = jsonParser.nextToken(); } } else { throw new IOException("Expected an object for the subnodes"); } } else if (label.equals(ContentTypeDefinitions.LABEL_SUBNODES)) { if (token.equals(JsonToken.START_OBJECT)) { token = jsonParser.nextToken(); try { while (!token.equals(JsonToken.END_OBJECT)) { final String subnodeType = jsonParser.getCurrentName(); token = jsonParser.nextToken(); if (token.equals(JsonToken.START_OBJECT)) { jsonParser.skipChildren(); token = jsonParser.nextToken(); } } } catch (final IOException e) { throw new IOException("unable to skip child of sub-nodes", e); } } else { final String field = jsonParser.getValueAsString(); throw new IOException("Expected an object for the subnodes. Instead: " + field); } } else if (label.equals(ContentTypeDefinitions.LABEL_TALLY)) { UGCImportHelper.extractTally(post, jsonParser, resProvider, tallyOperationsService); } else if (label.equals(ContentTypeDefinitions.LABEL_TRANSLATION)) { importTranslation(jsonParser, post); resProvider.commit(post.getResourceResolver()); } } else if (jsonParser.getCurrentToken().equals(JsonToken.START_OBJECT)) { properties.put(label, UGCImportHelper.extractSubmap(jsonParser)); } else if (jsonParser.getCurrentToken().equals(JsonToken.START_ARRAY)) { jsonParser.nextToken(); // skip the START_ARRAY token if (label.equals(ContentTypeDefinitions.LABEL_TIMESTAMP_FIELDS)) { while (!jsonParser.getCurrentToken().equals(JsonToken.END_ARRAY)) { final String timestampLabel = jsonParser.getValueAsString(); if (properties.containsKey(timestampLabel) && properties.get(timestampLabel) instanceof Long) { final Calendar calendar = new GregorianCalendar(); calendar.setTimeInMillis((Long) properties.get(timestampLabel)); properties.put(timestampLabel, calendar.getTime()); } jsonParser.nextToken(); } } else { final List<String> subArray = new ArrayList<String>(); while (!jsonParser.getCurrentToken().equals(JsonToken.END_ARRAY)) { subArray.add(jsonParser.getValueAsString()); jsonParser.nextToken(); } String[] strings = new String[subArray.size()]; for (int i = 0; i < subArray.size(); i++) { strings[i] = subArray.get(i); } properties.put(label, strings); } } jsonParser.nextToken(); } if (post == null) { try { post = createPost(resource, author, properties, attachments, resolver.adaptTo(Session.class), operations); if (null == resProvider) { resProvider = SocialResourceUtils.getSocialResource(post).getResourceProvider(); } // resProvider.commit(resolver); } catch (Exception e) { throw new ServletException(e.getMessage(), e); } } } else { throw new IOException("Improperly formed JSON - expected an OBJECT_START token, but got " + jsonParser.getCurrentToken().toString()); } }
From source file:org.apache.hadoop.hbase.rest.TestTableScan.java
@Test public void testStreamingJSON() throws Exception { //Test with start row and end row. StringBuilder builder = new StringBuilder(); builder.append("/*"); builder.append("?"); builder.append(Constants.SCAN_COLUMN + "=" + COLUMN_1); builder.append("&"); builder.append(Constants.SCAN_START_ROW + "=aaa"); builder.append("&"); builder.append(Constants.SCAN_END_ROW + "=aay"); Response response = client.get("/" + TABLE + builder.toString(), Constants.MIMETYPE_JSON); assertEquals(200, response.getCode()); int count = 0; ObjectMapper mapper = new JacksonJaxbJsonProvider().locateMapper(CellSetModel.class, MediaType.APPLICATION_JSON_TYPE); JsonFactory jfactory = new JsonFactory(mapper); JsonParser jParser = jfactory.createJsonParser(response.getStream()); boolean found = false; while (jParser.nextToken() != JsonToken.END_OBJECT) { if (jParser.getCurrentToken() == JsonToken.START_OBJECT && found) { RowModel row = jParser.readValueAs(RowModel.class); assertNotNull(row.getKey()); for (int i = 0; i < row.getCells().size(); i++) { if (count == 0) { assertEquals("aaa", Bytes.toString(row.getKey())); }//www .j av a 2 s . c o m if (count == 23) { assertEquals("aax", Bytes.toString(row.getKey())); } count++; } jParser.skipChildren(); } else { found = jParser.getCurrentToken() == JsonToken.START_ARRAY; } } assertEquals(24, count); }
From source file:org.jbpm.designer.bpmn2.impl.Bpmn2JsonUnmarshaller.java
public BaseElement unmarshallItem(JsonParser parser, String preProcessingData) throws JsonParseException, IOException { String resourceId = null;/*from w w w .j a va 2s. c o m*/ Map<String, String> properties = null; String stencil = null; List<BaseElement> childElements = new ArrayList<BaseElement>(); List<String> outgoing = new ArrayList<String>(); while (parser.nextToken() != JsonToken.END_OBJECT) { String fieldname = parser.getCurrentName(); parser.nextToken(); if ("resourceId".equals(fieldname)) { resourceId = parser.getText(); } else if ("properties".equals(fieldname)) { properties = unmarshallProperties(parser); } else if ("stencil".equals(fieldname)) { // "stencil":{"id":"Task"}, parser.nextToken(); parser.nextToken(); stencil = parser.getText(); parser.nextToken(); } else if ("childShapes".equals(fieldname)) { while (parser.nextToken() != JsonToken.END_ARRAY) { // open the // object // the childShapes element is a json array. We opened the // array. childElements.add(unmarshallItem(parser, preProcessingData)); } } else if ("bounds".equals(fieldname)) { // bounds: {"lowerRight":{"x":484.0,"y":198.0},"upperLeft":{"x":454.0,"y":168.0}} parser.nextToken(); parser.nextToken(); parser.nextToken(); parser.nextToken(); Integer x2 = parser.getIntValue(); parser.nextToken(); parser.nextToken(); Integer y2 = parser.getIntValue(); parser.nextToken(); parser.nextToken(); parser.nextToken(); parser.nextToken(); parser.nextToken(); Integer x1 = parser.getIntValue(); parser.nextToken(); parser.nextToken(); Integer y1 = parser.getIntValue(); parser.nextToken(); parser.nextToken(); // by default the org.eclipse.dd.dc bounds says // its features are set if they are non-zero // we need to change that so that nodes placed on the canvas borders // where x or y can be zero still are treated as set features // otherwise they will not end up as attributes in the produced xml BoundsImpl b = new BoundsImpl() { @Override public boolean eIsSet(int featureID) { switch (featureID) { case 0: if (this.height >= 0.0F) { return true; } return false; case 1: if (this.width >= 0.0F) { return true; } return false; case 2: if (this.x >= 0.0F) { return true; } return false; case 3: if (this.y >= 0.0F) { return true; } return false; default: return super.eIsSet(featureID); } } }; b.setX(x1); b.setY(y1); b.setWidth(x2 - x1); b.setHeight(y2 - y1); this._bounds.put(resourceId, b); } else if ("dockers".equals(fieldname)) { // "dockers":[{"x":50,"y":40},{"x":353.5,"y":115},{"x":353.5,"y":152},{"x":50,"y":40}], List<Point> dockers = new ArrayList<Point>(); JsonToken nextToken = parser.nextToken(); boolean end = JsonToken.END_ARRAY.equals(nextToken); while (!end) { nextToken = parser.nextToken(); nextToken = parser.nextToken(); Integer x = parser.getIntValue(); parser.nextToken(); parser.nextToken(); Integer y = parser.getIntValue(); Point point = DcFactory.eINSTANCE.createPoint(); point.setX(x); point.setY(y); dockers.add(point); parser.nextToken(); nextToken = parser.nextToken(); end = JsonToken.END_ARRAY.equals(nextToken); } this._dockers.put(resourceId, dockers); } else if ("outgoing".equals(fieldname)) { while (parser.nextToken() != JsonToken.END_ARRAY) { // {resourceId: oryx_1AAA8C9A-39A5-42FC-8ED1-507A7F3728EA} parser.nextToken(); parser.nextToken(); outgoing.add(parser.getText()); parser.nextToken(); } // pass on the array parser.skipChildren(); } else if ("target".equals(fieldname)) { // we already collected that info with the outgoing field. parser.skipChildren(); // "target": { // "resourceId": "oryx_A75E7546-DF71-48EA-84D3-2A8FD4A47568" // } // add to the map: // parser.nextToken(); // resourceId: // parser.nextToken(); // the value we want to save // targetId = parser.getText(); // parser.nextToken(); // }, closing the object } } properties.put("resourceId", resourceId); boolean customElement = isCustomElement(properties.get("tasktype"), preProcessingData); BaseElement baseElt = this.createBaseElement(stencil, properties.get("tasktype"), customElement); // register the sequence flow targets. if (baseElt instanceof SequenceFlow) { _sequenceFlowTargets.addAll(outgoing); } _outgoingFlows.put(baseElt, outgoing); _objMap.put(baseElt, resourceId); // keep the object around to do connections _idMap.put(resourceId, baseElt); // baseElt.setId(resourceId); commented out as bpmn2 seems to create // duplicate ids right now. applyProperties(baseElt, properties, preProcessingData); if (baseElt instanceof Definitions) { Process rootLevelProcess = null; if (childElements == null || childElements.size() < 1) { if (rootLevelProcess == null) { rootLevelProcess = Bpmn2Factory.eINSTANCE.createProcess(); // set the properties and item definitions first if (properties.get("vardefs") != null && properties.get("vardefs").length() > 0) { String[] vardefs = properties.get("vardefs").split(",\\s*"); for (String vardef : vardefs) { Property prop = Bpmn2Factory.eINSTANCE.createProperty(); ItemDefinition itemdef = Bpmn2Factory.eINSTANCE.createItemDefinition(); // check if we define a structure ref in the definition if (vardef.contains(":")) { String[] vardefParts = vardef.split(":\\s*"); prop.setId(vardefParts[0]); itemdef.setId("_" + prop.getId() + "Item"); boolean haveKPI = false; String kpiValue = ""; if (vardefParts.length == 3) { itemdef.setStructureRef(vardefParts[1]); if (vardefParts[2].equals("true")) { haveKPI = true; kpiValue = vardefParts[2]; } } if (vardefParts.length == 2) { if (vardefParts[1].equals("true") || vardefParts[1].equals("false")) { if (vardefParts[1].equals("true")) { haveKPI = true; kpiValue = vardefParts[1]; } } else { itemdef.setStructureRef(vardefParts[1]); } } if (haveKPI) { Utils.setMetaDataExtensionValue(prop, "customKPI", wrapInCDATABlock(kpiValue)); } } else { prop.setId(vardef); itemdef.setId("_" + prop.getId() + "Item"); } prop.setItemSubjectRef(itemdef); rootLevelProcess.getProperties().add(prop); ((Definitions) baseElt).getRootElements().add(itemdef); } } if (properties.get("adhocprocess") != null && properties.get("adhocprocess").equals("true")) { ExtendedMetaData metadata = ExtendedMetaData.INSTANCE; EAttributeImpl extensionAttribute = (EAttributeImpl) metadata .demandFeature("http://www.jboss.org/drools", "adHoc", false, false); SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute, properties.get("adhocprocess")); rootLevelProcess.getAnyAttribute().add(extensionEntry); } if (properties.get("customdescription") != null && properties.get("customdescription").length() > 0) { Utils.setMetaDataExtensionValue(rootLevelProcess, "customDescription", wrapInCDATABlock(properties.get("customdescription"))); } if (properties.get("customcaseidprefix") != null && properties.get("customcaseidprefix").length() > 0) { Utils.setMetaDataExtensionValue(rootLevelProcess, "customCaseIdPrefix", wrapInCDATABlock(properties.get("customcaseidprefix"))); } if (properties.get("customcaseroles") != null && properties.get("customcaseroles").length() > 0) { Utils.setMetaDataExtensionValue(rootLevelProcess, "customCaseRoles", wrapInCDATABlock(properties.get("customcaseroles"))); } // customsladuedate metadata applySlaDueDateProperties(rootLevelProcess, properties); rootLevelProcess.setId(properties.get("id")); applyProcessProperties(rootLevelProcess, properties); ((Definitions) baseElt).getRootElements().add(rootLevelProcess); } } else { for (BaseElement child : childElements) { // tasks are only permitted under processes. // a process should be created implicitly for tasks at the root // level. // process designer doesn't make a difference between tasks and // global tasks. // if a task has sequence edges it is considered a task, // otherwise it is considered a global task. // if (child instanceof Task && _outgoingFlows.get(child).isEmpty() && !_sequenceFlowTargets.contains(_objMap.get(child))) { // // no edges on a task at the top level! We replace it with a // // global task. // GlobalTask task = null; // if (child instanceof ScriptTask) { // task = Bpmn2Factory.eINSTANCE.createGlobalScriptTask(); // ((GlobalScriptTask) task).setScript(((ScriptTask) child).getScript()); // ((GlobalScriptTask) task).setScriptLanguage(((ScriptTask) child).getScriptFormat()); // // TODO scriptLanguage missing on scriptTask // } else if (child instanceof UserTask) { // task = Bpmn2Factory.eINSTANCE.createGlobalUserTask(); // } else if (child instanceof ServiceTask) { // // we don't have a global service task! Fallback on a // // normal global task // task = Bpmn2Factory.eINSTANCE.createGlobalTask(); // } else if (child instanceof BusinessRuleTask) { // task = Bpmn2Factory.eINSTANCE.createGlobalBusinessRuleTask(); // } else if (child instanceof ManualTask) { // task = Bpmn2Factory.eINSTANCE.createGlobalManualTask(); // } else { // task = Bpmn2Factory.eINSTANCE.createGlobalTask(); // } // // task.setName(((Task) child).getName()); // task.setIoSpecification(((Task) child).getIoSpecification()); // task.getDocumentation().addAll(((Task) child).getDocumentation()); // ((Definitions) baseElt).getRootElements().add(task); // continue; // } else { if (child instanceof SequenceFlow) { // for some reason sequence flows are placed as root elements. // find if the target has a container, and if we can use it: List<String> ids = _outgoingFlows.get(child); FlowElementsContainer container = null; for (String id : ids) { // yes, we iterate, but we'll take the first in the list that will work. Object obj = _idMap.get(id); if (obj instanceof EObject && ((EObject) obj).eContainer() instanceof FlowElementsContainer) { container = (FlowElementsContainer) ((EObject) obj).eContainer(); break; } } if (container != null) { container.getFlowElements().add((SequenceFlow) child); continue; } } if (child instanceof Task || child instanceof SequenceFlow || child instanceof Gateway || child instanceof Event || child instanceof Artifact || child instanceof DataObject || child instanceof SubProcess || child instanceof Lane || child instanceof CallActivity || child instanceof TextAnnotation) { if (rootLevelProcess == null) { rootLevelProcess = Bpmn2Factory.eINSTANCE.createProcess(); // set the properties and item definitions first if (properties.get("vardefs") != null && properties.get("vardefs").length() > 0) { String[] vardefs = properties.get("vardefs").split(",\\s*"); for (String vardef : vardefs) { Property prop = Bpmn2Factory.eINSTANCE.createProperty(); ItemDefinition itemdef = Bpmn2Factory.eINSTANCE.createItemDefinition(); // check if we define a structure ref in the definition if (vardef.contains(":")) { String[] vardefParts = vardef.split(":\\s*"); prop.setId(vardefParts[0]); itemdef.setId("_" + prop.getId() + "Item"); boolean haveKPI = false; String kpiValue = ""; if (vardefParts.length == 3) { itemdef.setStructureRef(vardefParts[1]); if (vardefParts[2].equals("true")) { haveKPI = true; kpiValue = vardefParts[2]; } } if (vardefParts.length == 2) { if (vardefParts[1].equals("true") || vardefParts[1].equals("false")) { if (vardefParts[1].equals("true")) { haveKPI = true; kpiValue = vardefParts[1]; } } else { itemdef.setStructureRef(vardefParts[1]); } } if (haveKPI) { Utils.setMetaDataExtensionValue(prop, "customKPI", wrapInCDATABlock(kpiValue)); } } else { prop.setId(vardef); itemdef.setId("_" + prop.getId() + "Item"); } prop.setItemSubjectRef(itemdef); rootLevelProcess.getProperties().add(prop); ((Definitions) baseElt).getRootElements().add(itemdef); } } if (properties.get("adhocprocess") != null && properties.get("adhocprocess").equals("true")) { ExtendedMetaData metadata = ExtendedMetaData.INSTANCE; EAttributeImpl extensionAttribute = (EAttributeImpl) metadata .demandFeature("http://www.jboss.org/drools", "adHoc", false, false); SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute, properties.get("adhocprocess")); rootLevelProcess.getAnyAttribute().add(extensionEntry); } if (properties.get("customdescription") != null && properties.get("customdescription").length() > 0) { Utils.setMetaDataExtensionValue(rootLevelProcess, "customDescription", wrapInCDATABlock(properties.get("customdescription"))); } if (properties.get("customcaseidprefix") != null && properties.get("customcaseidprefix").length() > 0) { Utils.setMetaDataExtensionValue(rootLevelProcess, "customCaseIdPrefix", wrapInCDATABlock(properties.get("customcaseidprefix"))); } if (properties.get("customcaseroles") != null && properties.get("customcaseroles").length() > 0) { Utils.setMetaDataExtensionValue(rootLevelProcess, "customCaseRoles", wrapInCDATABlock(properties.get("customcaseroles"))); } // customsladuedate metadata applySlaDueDateProperties(rootLevelProcess, properties); rootLevelProcess.setId(properties.get("id")); applyProcessProperties(rootLevelProcess, properties); ((Definitions) baseElt).getRootElements().add(rootLevelProcess); } } if (child instanceof Task) { rootLevelProcess.getFlowElements().add((Task) child); } else if (child instanceof CallActivity) { rootLevelProcess.getFlowElements().add((CallActivity) child); } else if (child instanceof RootElement) { ((Definitions) baseElt).getRootElements().add((RootElement) child); } else if (child instanceof SequenceFlow) { rootLevelProcess.getFlowElements().add((SequenceFlow) child); } else if (child instanceof Gateway) { rootLevelProcess.getFlowElements().add((Gateway) child); } else if (child instanceof Event) { rootLevelProcess.getFlowElements().add((Event) child); } else if (child instanceof TextAnnotation) { rootLevelProcess.getFlowElements().add((TextAnnotation) child); } else if (child instanceof Artifact) { rootLevelProcess.getArtifacts().add((Artifact) child); } else if (child instanceof DataObject) { // bubble up data objects //rootLevelProcess.getFlowElements().add(0, (DataObject) child); rootLevelProcess.getFlowElements().add((DataObject) child); // ItemDefinition def = ((DataObject) child).getItemSubjectRef(); // if (def != null) { // if (def.eResource() == null) { // ((Definitions) rootLevelProcess.eContainer()).getRootElements().add(0, def); // } // Import imported = def.getImport(); // if (imported != null && imported.eResource() == null) { // ((Definitions) rootLevelProcess.eContainer()).getImports().add(0, imported); // } // } } else if (child instanceof SubProcess) { rootLevelProcess.getFlowElements().add((SubProcess) child); } else if (child instanceof Lane) { // lanes handled later } else { _logger.error("Don't know what to do of " + child); } // } } } } else if (baseElt instanceof Process) { for (BaseElement child : childElements) { if (child instanceof Lane) { if (((Process) baseElt).getLaneSets().isEmpty()) { ((Process) baseElt).getLaneSets().add(Bpmn2Factory.eINSTANCE.createLaneSet()); } ((Process) baseElt).getLaneSets().get(0).getLanes().add((Lane) child); addLaneFlowNodes((Process) baseElt, (Lane) child); } else if (child instanceof Artifact) { ((Process) baseElt).getArtifacts().add((Artifact) child); } else { _logger.error("Don't know what to do of " + child); } } } else if (baseElt instanceof SubProcess) { for (BaseElement child : childElements) { if (child instanceof FlowElement) { ((SubProcess) baseElt).getFlowElements().add((FlowElement) child); } else if (child instanceof Artifact) { ((SubProcess) baseElt).getArtifacts().add((Artifact) child); } else { _logger.error("Subprocess - don't know what to do of " + child); } } } else if (baseElt instanceof Message) { // we do not support base-element messages from the json. They are created dynamically for events that use them. } else if (baseElt instanceof Lane) { for (BaseElement child : childElements) { if (child instanceof FlowNode) { ((Lane) baseElt).getFlowNodeRefs().add((FlowNode) child); } // no support for child-lanes at this point // else if (child instanceof Lane) { // if (((Lane) baseElt).getChildLaneSet() == null) { // ((Lane) baseElt).setChildLaneSet(Bpmn2Factory.eINSTANCE.createLaneSet()); // } // ((Lane) baseElt).getChildLaneSet().getLanes().add((Lane) child); // } else if (child instanceof Artifact) { _artifacts.add((Artifact) child); } else { _logger.error("Don't know what to do of " + childElements); } } _lanes.add((Lane) baseElt); } else { if (!childElements.isEmpty()) { _logger.error("Don't know what to do of " + childElements + " with " + baseElt); } } return baseElt; }
From source file:org.kie.workbench.common.stunner.bpmn.backend.legacy.Bpmn2JsonUnmarshaller.java
public BaseElement unmarshallItem(JsonParser parser, String preProcessingData) throws IOException { String resourceId = null;// w w w .j a v a2 s .c o m Map<String, String> properties = null; String stencil = null; List<BaseElement> childElements = new ArrayList<BaseElement>(); List<String> outgoing = new ArrayList<String>(); while (parser.nextToken() != JsonToken.END_OBJECT) { String fieldname = parser.getCurrentName(); parser.nextToken(); if ("resourceId".equals(fieldname)) { resourceId = parser.getText(); } else if ("properties".equals(fieldname)) { properties = unmarshallProperties(parser); } else if ("stencil".equals(fieldname)) { // "stencil":{"id":"Task"}, parser.nextToken(); parser.nextToken(); stencil = parser.getText(); parser.nextToken(); } else if ("childShapes".equals(fieldname)) { while (parser.nextToken() != JsonToken.END_ARRAY) { // open the // object // the childShapes element is a json array. We opened the // array. childElements.add(unmarshallItem(parser, preProcessingData)); } } else if ("bounds".equals(fieldname)) { // bounds: {"lowerRight":{"x":484.0,"y":198.0},"upperLeft":{"x":454.0,"y":168.0}} parser.nextToken(); parser.nextToken(); parser.nextToken(); parser.nextToken(); Integer x2 = parser.getIntValue(); parser.nextToken(); parser.nextToken(); Integer y2 = parser.getIntValue(); parser.nextToken(); parser.nextToken(); parser.nextToken(); parser.nextToken(); parser.nextToken(); Integer x1 = parser.getIntValue(); parser.nextToken(); parser.nextToken(); Integer y1 = parser.getIntValue(); parser.nextToken(); parser.nextToken(); Bounds b = DcFactory.eINSTANCE.createBounds(); b.setX(x1); b.setY(y1); b.setWidth(x2 - x1); b.setHeight(y2 - y1); this._bounds.put(resourceId, b); } else if ("dockers".equals(fieldname)) { // "dockers":[{"x":50,"y":40},{"x":353.5,"y":115},{"x":353.5,"y":152},{"x":50,"y":40}], List<Point> dockers = new ArrayList<Point>(); JsonToken nextToken = parser.nextToken(); boolean end = JsonToken.END_ARRAY.equals(nextToken); while (!end) { nextToken = parser.nextToken(); nextToken = parser.nextToken(); Integer x = parser.getIntValue(); parser.nextToken(); parser.nextToken(); Integer y = parser.getIntValue(); Point point = DcFactory.eINSTANCE.createPoint(); point.setX(x); point.setY(y); dockers.add(point); parser.nextToken(); nextToken = parser.nextToken(); end = JsonToken.END_ARRAY.equals(nextToken); } this._dockers.put(resourceId, dockers); } else if ("outgoing".equals(fieldname)) { while (parser.nextToken() != JsonToken.END_ARRAY) { // {resourceId: oryx_1AAA8C9A-39A5-42FC-8ED1-507A7F3728EA} parser.nextToken(); parser.nextToken(); outgoing.add(parser.getText()); parser.nextToken(); } // pass on the array parser.skipChildren(); } else if ("target".equals(fieldname)) { // we already collected that info with the outgoing field. parser.skipChildren(); // "target": { // "resourceId": "oryx_A75E7546-DF71-48EA-84D3-2A8FD4A47568" // } // add to the map: // parser.nextToken(); // resourceId: // parser.nextToken(); // the value we want to save // targetId = parser.getText(); // parser.nextToken(); // }, closing the object } } properties.put("resourceId", resourceId); boolean customElement = isCustomElement(properties.get("tasktype"), preProcessingData); BaseElement baseElt = this.createBaseElement(stencil, properties.get("tasktype"), customElement); // register the sequence flow targets. if (baseElt instanceof SequenceFlow) { _sequenceFlowTargets.addAll(outgoing); } _outgoingFlows.put(baseElt, outgoing); _objMap.put(baseElt, resourceId); // keep the object around to do connections _idMap.put(resourceId, baseElt); // baseElt.setId(resourceId); commented out as bpmn2 seems to create // duplicate ids right now. applyProperties(baseElt, properties, preProcessingData); if (baseElt instanceof Definitions) { Process rootLevelProcess = null; if (childElements == null || childElements.size() < 1) { if (rootLevelProcess == null) { rootLevelProcess = Bpmn2Factory.eINSTANCE.createProcess(); // set the properties and item definitions first if (properties.get("vardefs") != null && properties.get("vardefs").length() > 0) { String[] vardefs = properties.get("vardefs").split(",\\s*"); for (String vardef : vardefs) { Property prop = Bpmn2Factory.eINSTANCE.createProperty(); ItemDefinition itemdef = Bpmn2Factory.eINSTANCE.createItemDefinition(); // check if we define a structure ref in the definition if (vardef.contains(":")) { String[] vardefParts = vardef.split(":\\s*"); prop.setId(vardefParts[0]); itemdef.setId("_" + prop.getId() + "Item"); boolean haveKPI = false; String kpiValue = ""; if (vardefParts.length == 3) { itemdef.setStructureRef(vardefParts[1]); if (vardefParts[2].equals("true")) { haveKPI = true; kpiValue = vardefParts[2]; } } if (vardefParts.length == 2) { if (vardefParts[1].equals("true") || vardefParts[1].equals("false")) { if (vardefParts[1].equals("true")) { haveKPI = true; kpiValue = vardefParts[1]; } } else { itemdef.setStructureRef(vardefParts[1]); } } if (haveKPI) { Utils.setMetaDataExtensionValue(prop, "customKPI", wrapInCDATABlock(kpiValue)); } } else { prop.setId(vardef); itemdef.setId("_" + prop.getId() + "Item"); } prop.setItemSubjectRef(itemdef); rootLevelProcess.getProperties().add(prop); ((Definitions) baseElt).getRootElements().add(itemdef); } } if (properties.get("adhocprocess") != null && properties.get("adhocprocess").equals("true")) { ExtendedMetaData metadata = ExtendedMetaData.INSTANCE; EAttributeImpl extensionAttribute = (EAttributeImpl) metadata .demandFeature("http://www.jboss.org/drools", "adHoc", false, false); SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute, properties.get("adhocprocess")); rootLevelProcess.getAnyAttribute().add(extensionEntry); } if (properties.get("customdescription") != null && properties.get("customdescription").length() > 0) { Utils.setMetaDataExtensionValue(rootLevelProcess, "customDescription", wrapInCDATABlock(properties.get("customdescription"))); } rootLevelProcess.setId(properties.get("id")); applyProcessProperties(rootLevelProcess, properties); ((Definitions) baseElt).getRootElements().add(rootLevelProcess); } } else { for (BaseElement child : childElements) { // tasks are only permitted under processes. // a process should be created implicitly for tasks at the root // level. // process designer doesn't make a difference between tasks and // global tasks. // if a task has sequence edges it is considered a task, // otherwise it is considered a global task. // if (child instanceof Task && _outgoingFlows.get(child).isEmpty() && !_sequenceFlowTargets.contains(_objMap.get(child))) { // // no edges on a task at the top level! We replace it with a // // global task. // GlobalTask task = null; // if (child instanceof ScriptTask) { // task = Bpmn2Factory.eINSTANCE.createGlobalScriptTask(); // ((GlobalScriptTask) task).setScript(((ScriptTask) child).getScript()); // ((GlobalScriptTask) task).setScriptLanguage(((ScriptTask) child).getScriptFormat()); // // TODO scriptLanguage missing on scriptTask // } else if (child instanceof UserTask) { // task = Bpmn2Factory.eINSTANCE.createGlobalUserTask(); // } else if (child instanceof ServiceTask) { // // we don't have a global service task! Fallback on a // // normal global task // task = Bpmn2Factory.eINSTANCE.createGlobalTask(); // } else if (child instanceof BusinessRuleTask) { // task = Bpmn2Factory.eINSTANCE.createGlobalBusinessRuleTask(); // } else if (child instanceof ManualTask) { // task = Bpmn2Factory.eINSTANCE.createGlobalManualTask(); // } else { // task = Bpmn2Factory.eINSTANCE.createGlobalTask(); // } // // task.setName(((Task) child).getName()); // task.setIoSpecification(((Task) child).getIoSpecification()); // task.getDocumentation().addAll(((Task) child).getDocumentation()); // ((Definitions) baseElt).getRootElements().add(task); // continue; // } else { if (child instanceof SequenceFlow) { // for some reason sequence flows are placed as root elements. // find if the target has a container, and if we can use it: List<String> ids = _outgoingFlows.get(child); FlowElementsContainer container = null; for (String id : ids) { // yes, we iterate, but we'll take the first in the list that will work. Object obj = _idMap.get(id); if (obj instanceof EObject && ((EObject) obj).eContainer() instanceof FlowElementsContainer) { container = (FlowElementsContainer) ((EObject) obj).eContainer(); break; } } if (container != null) { container.getFlowElements().add((SequenceFlow) child); continue; } } if (child instanceof Task || child instanceof SequenceFlow || child instanceof Gateway || child instanceof Event || child instanceof Artifact || child instanceof DataObject || child instanceof SubProcess || child instanceof Lane || child instanceof CallActivity || child instanceof TextAnnotation) { if (rootLevelProcess == null) { rootLevelProcess = Bpmn2Factory.eINSTANCE.createProcess(); // set the properties and item definitions first if (properties.get("vardefs") != null && properties.get("vardefs").length() > 0) { String[] vardefs = properties.get("vardefs").split(",\\s*"); for (String vardef : vardefs) { Property prop = Bpmn2Factory.eINSTANCE.createProperty(); ItemDefinition itemdef = Bpmn2Factory.eINSTANCE.createItemDefinition(); // check if we define a structure ref in the definition if (vardef.contains(":")) { String[] vardefParts = vardef.split(":\\s*"); prop.setId(vardefParts[0]); itemdef.setId("_" + prop.getId() + "Item"); boolean haveKPI = false; String kpiValue = ""; if (vardefParts.length == 3) { itemdef.setStructureRef(vardefParts[1]); if (vardefParts[2].equals("true")) { haveKPI = true; kpiValue = vardefParts[2]; } } if (vardefParts.length == 2) { if (vardefParts[1].equals("true") || vardefParts[1].equals("false")) { if (vardefParts[1].equals("true")) { haveKPI = true; kpiValue = vardefParts[1]; } } else { itemdef.setStructureRef(vardefParts[1]); } } if (haveKPI) { Utils.setMetaDataExtensionValue(prop, "customKPI", wrapInCDATABlock(kpiValue)); } } else { prop.setId(vardef); itemdef.setId("_" + prop.getId() + "Item"); } prop.setItemSubjectRef(itemdef); rootLevelProcess.getProperties().add(prop); ((Definitions) baseElt).getRootElements().add(itemdef); } } if (properties.get("adhocprocess") != null && properties.get("adhocprocess").equals("true")) { ExtendedMetaData metadata = ExtendedMetaData.INSTANCE; EAttributeImpl extensionAttribute = (EAttributeImpl) metadata .demandFeature("http://www.jboss.org/drools", "adHoc", false, false); SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute, properties.get("adhocprocess")); rootLevelProcess.getAnyAttribute().add(extensionEntry); } if (properties.get("customdescription") != null && properties.get("customdescription").length() > 0) { Utils.setMetaDataExtensionValue(rootLevelProcess, "customDescription", wrapInCDATABlock(properties.get("customdescription"))); } rootLevelProcess.setId(properties.get("id")); applyProcessProperties(rootLevelProcess, properties); ((Definitions) baseElt).getRootElements().add(rootLevelProcess); } } if (child instanceof Task) { rootLevelProcess.getFlowElements().add((Task) child); } else if (child instanceof CallActivity) { rootLevelProcess.getFlowElements().add((CallActivity) child); } else if (child instanceof RootElement) { ((Definitions) baseElt).getRootElements().add((RootElement) child); } else if (child instanceof SequenceFlow) { rootLevelProcess.getFlowElements().add((SequenceFlow) child); } else if (child instanceof Gateway) { rootLevelProcess.getFlowElements().add((Gateway) child); } else if (child instanceof Event) { rootLevelProcess.getFlowElements().add((Event) child); } else if (child instanceof TextAnnotation) { rootLevelProcess.getFlowElements().add((TextAnnotation) child); } else if (child instanceof Artifact) { rootLevelProcess.getArtifacts().add((Artifact) child); } else if (child instanceof DataObject) { // bubble up data objects //rootLevelProcess.getFlowElements().add(0, (DataObject) child); rootLevelProcess.getFlowElements().add((DataObject) child); // ItemDefinition def = ((DataObject) child).getItemSubjectRef(); // if (def != null) { // if (def.eResource() == null) { // ((Definitions) rootLevelProcess.eContainer()).getRootElements().add(0, def); // } // Import imported = def.getImport(); // if (imported != null && imported.eResource() == null) { // ((Definitions) rootLevelProcess.eContainer()).getImports().add(0, imported); // } // } } else if (child instanceof SubProcess) { rootLevelProcess.getFlowElements().add((SubProcess) child); } else if (child instanceof Lane) { // lanes handled later } else { _logger.error("Don't know what to do of " + child); } // } } } } else if (baseElt instanceof Process) { for (BaseElement child : childElements) { if (child instanceof Lane) { if (((Process) baseElt).getLaneSets().isEmpty()) { ((Process) baseElt).getLaneSets().add(Bpmn2Factory.eINSTANCE.createLaneSet()); } ((Process) baseElt).getLaneSets().get(0).getLanes().add((Lane) child); addLaneFlowNodes((Process) baseElt, (Lane) child); } else if (child instanceof Artifact) { ((Process) baseElt).getArtifacts().add((Artifact) child); } else { _logger.error("Don't know what to do of " + child); } } } else if (baseElt instanceof SubProcess) { for (BaseElement child : childElements) { if (child instanceof FlowElement) { ((SubProcess) baseElt).getFlowElements().add((FlowElement) child); } else if (child instanceof Artifact) { ((SubProcess) baseElt).getArtifacts().add((Artifact) child); } else { _logger.error("Subprocess - don't know what to do of " + child); } } } else if (baseElt instanceof Message) { // we do not support base-element messages from the json. They are created dynamically for events that use them. } else if (baseElt instanceof Lane) { for (BaseElement child : childElements) { if (child instanceof FlowNode) { ((Lane) baseElt).getFlowNodeRefs().add((FlowNode) child); } // no support for child-lanes at this point // else if (child instanceof Lane) { // if (((Lane) baseElt).getChildLaneSet() == null) { // ((Lane) baseElt).setChildLaneSet(Bpmn2Factory.eINSTANCE.createLaneSet()); // } // ((Lane) baseElt).getChildLaneSet().getLanes().add((Lane) child); // } else if (child instanceof Artifact) { _artifacts.add((Artifact) child); } else { _logger.error("Don't know what to do of " + childElements); } } _lanes.add((Lane) baseElt); } else { if (!childElements.isEmpty()) { _logger.error("Don't know what to do of " + childElements + " with " + baseElt); } } return baseElt; }