private String getText(Archetype ar, CObject constrainedObj, String language) { String text = getText(ar, constrainedObj.getNodeId(), language); if (text != null) { return text; } else { Archetype archetype = archetypeMap.get(constrainedObj.getNodeId()); if (archetype != null) { text = archetype.getConceptName(language); } else { text = constrainedObj.getNodeId(); } return text; } }
private boolean hasSiblingNodeWithNodeId(CAttribute parent, String nodeId) { for (CObject cobj : parent.getChildren()) { if (nodeId.equals(cobj.getNodeId())) { return true; } } return false; }
private int countChildOfArchetypeId(CAttribute cattr, String archetypeId) { int count = 0; for(CObject cobj : cattr.getChildren()) { String nodeId = cobj.getNodeId(); if(nodeId == null) { continue; } if(nodeId.startsWith(archetypeId)) { count++; } } return count; }
private int countChildOfArchetypeId(CAttribute cattr, String archetypeId) { int count = 0; for (CObject cobj : cattr.getChildren()) { String nodeId = cobj.getNodeId(); if (nodeId == null) { continue; } if (nodeId.startsWith(archetypeId)) { count++; } } return count; }
private int countChildOfArchetypeId(CAttribute cattr, String archetypeId) { int count = 0; for(CObject cobj : cattr.getChildren()) { String nodeId = cobj.getNodeId(); if(nodeId == null) { continue; } if(nodeId.startsWith(archetypeId)) { count++; } } return count; }
/** * Checks if there is any sibling node with the same node_id * * @param parent * @param nodeId * @return */ private boolean hasSiblingNodeWithNodeId(CAttribute parent, String nodeId) { for(CObject cobj : parent.getChildren()) { if(nodeId.equals(cobj.getNodeId())) { return true; } } return false; }
/** * Checks if there is any sibling node with the same node_id * * @param parent * @param nodeId * @return */ private boolean hasSiblingNodeWithNodeId(CAttribute parent, String nodeId) { for(CObject cobj : parent.getChildren()) { if(nodeId.equals(cobj.getNodeId())) { return true; } } return false; }
private String getDescription(Archetype ar, CObject constrainedObj, String language) { String desc = getDescription(ar, constrainedObj.getNodeId(), language); if (desc != null) { return desc; } else { Archetype archetype = archetypeMap.get(constrainedObj.getNodeId()); if (archetype != null) { String conceptCode = archetype.getConcept(); ArchetypeTerm term = archetype.getOntology().termDefinition(language, conceptCode); desc = term.getDescription(); } else { desc = constrainedObj.getNodeId(); } return desc; } }
private boolean checkSpecialisedNodeIdConformance(CObject parentNode, CComplexObject ccobj, int childSpecialisationDepth, List<ValidationError> errors) { //TODO THis is not used anywhere!! if (ccobj.getNodeId().equals(parentNode.getNodeId())) { return true; // identical, which is ok (non-specialised) } if (StringUtils.countMatches(ccobj.getNodeId(), ".") == childSpecialisationDepth) { return true; // correct number of specialisations. } errors.add(new ValidationError(ErrorType.VSONCI, null, ccobj.getNodeId(), parentNode.getNodeId())); return false; }
private void removeUnnamedSiblingNode(Archetype archetype, CAttribute parent, String nodeId) throws FlatteningException { for(Iterator<CObject> it = parent.getChildren().iterator(); it.hasNext();) { CObject cobj = it.next(); if(nodeId.equals(cobj.getNodeId())) { if( ! (cobj instanceof CComplexObject)) { throw new FlatteningException("unexpected constraint type: " + cobj.getClass() + " for node_id[" + nodeId + "] at " + parent.path()); } CComplexObject ccobj = (CComplexObject) cobj; if( ! ccobj.hasAttribute(NAME)) { it.remove(); // seems unnecessary // archetype.reloadNodeMaps(); log.debug("Unnamed sibling node[" + nodeId + "] removed.."); break; } } } }
private void removeUnnamedSiblingNode(Archetype archetype, CAttribute parent, String nodeId) throws FlatteningException { for (Iterator<CObject> it = parent.getChildren().iterator(); it.hasNext(); ) { CObject cobj = it.next(); if (nodeId.equals(cobj.getNodeId())) { if (!(cobj instanceof CComplexObject)) { throw new FlatteningException("unexpected constraint type: " + cobj.getClass() + " for node_id[" + nodeId + "] at " + parent.path()); } CComplexObject ccobj = (CComplexObject) cobj; if (!ccobj.hasAttribute(NAME)) { it.remove(); // seems unnecessary // archetype.reloadNodeMaps(); log.debug("Unnamed sibling node[" + nodeId + "] removed.."); break; } } } }
private void checkSiblingNodeIdAndName(CAttribute parent, String nodeId, String name) throws FlatteningException { for(CObject cobj : parent.getChildren()) { if(nodeId.equals(cobj.path()) && name.equals(cobj.getNodeId())) { throw new FlatteningException("duplicated node_id/name: " + nodeId + "/" + name + "at path: " + parent.path()); } } }
private void removeUnnamedSiblingNode(Archetype archetype, CAttribute parent, String nodeId) throws FlatteningException { for(Iterator<CObject> it = parent.getChildren().iterator(); it.hasNext();) { CObject cobj = it.next(); if(nodeId.equals(cobj.getNodeId())) { if( ! (cobj instanceof CComplexObject)) { throw new FlatteningException("unexpected constraint type: " + cobj.getClass() + " for node_id[" + nodeId + "] at " + parent.path()); } CComplexObject ccobj = (CComplexObject) cobj; if( ! ccobj.hasAttribute(NAME)) { it.remove(); // seems unnecessary // archetype.reloadNodeMaps(); log.debug("Unnamed sibling node[" + nodeId + "] removed.."); break; } } } }
private void checkSiblingNodeIdAndName(CAttribute parent, String nodeId, String name) throws FlatteningException { for (CObject cobj : parent.getChildren()) { if (nodeId.equals(cobj.path()) && name.equals(cobj.getNodeId())) { throw new FlatteningException("duplicated node_id/name: " + nodeId + "/" + name + "at path: " + parent.path()); } } }
private void checkSiblingNodeIdAndName(CAttribute parent, String nodeId, String name) throws FlatteningException { for(CObject cobj : parent.getChildren()) { if(nodeId.equals(cobj.path()) && name.equals(cobj.getNodeId())) { throw new FlatteningException("duplicated node_id/name: " + nodeId + "/" + name + "at path: " + parent.path()); } } }
protected int findLargestNodeId(CObject cobj, int largest) throws FlatteningException { int current = largest; int last = 0; current = parseNodeId(cobj.getNodeId()); if (largest > current) { current = largest; } if (cobj instanceof CComplexObject) { CComplexObject ccobj = (CComplexObject) cobj; for (CAttribute cattr : ccobj.getAttributes()) { for (CObject child : cattr.getChildren()) { last = findLargestNodeId(child, current); if (last > current) { current = last; } } } } return current; }
protected long adjustNodeIds(CObject cobj, long count) throws FlatteningException { if (cobj.getNodeId() != null) { count++; cobj.setNodeId(formatNodeId(count)); } if (cobj instanceof CComplexObject) { for (CAttribute attr : ((CComplexObject) cobj).getAttributes()) { for (CObject child : attr.getChildren()) { count = adjustNodeIds(child, count); } } } return count; }
protected void printCObjectElements(CObject cobj, Element out) { // we always need the upper case with underscore notation for the rm type name printString("rm_type_name", getUpperCaseWithUnderscoreFromCamelCase(cobj.getRmTypeName()), out); printOccurrences(cobj.getOccurrences(), out); printString("node_id", cobj.getNodeId(), out); }
/** * Overwrite recursively all the nodeIds in the given cobj tree with * incremental number starting with given count value * * @param ccobj * @param diff * @return total number of nodeIds adjusted, used to update nodeId counter */ protected long adjustNodeIds(CObject cobj, long count) throws FlatteningException { if(cobj.getNodeId() != null) { count++; cobj.setNodeId(formatNodeId(count)); } if(cobj instanceof CComplexObject) { for(CAttribute attr : ((CComplexObject) cobj).getAttributes()) { for(CObject child : attr.getChildren()) { count = adjustNodeIds(child, count); } } } return count; }
/** * Overwrite recursively all the nodeIds in the given cobj tree with * incremental number starting with given count value * * @param ccobj * @param diff * @return total number of nodeIds adjusted, used to update nodeId counter */ protected long adjustNodeIds(CObject cobj, long count) throws FlatteningException { if(cobj.getNodeId() != null) { count++; cobj.setNodeId(formatNodeId(count)); } if(cobj instanceof CComplexObject) { for(CAttribute attr : ((CComplexObject) cobj).getAttributes()) { for(CObject child : attr.getChildren()) { count = adjustNodeIds(child, count); } } } return count; }