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); }
private void processCObject(CObject constrainedObj) { String path = constrainedObj.path(); String archetypeId = ar.getArchetypeId().getValue(); if (!OpenEHRConst.PARSABLE_OPENEHR_RM_NAMES.contains(constrainedObj.getRmTypeName())) { return; } if (constrainedObj instanceof CComplexObject) { processComplexObject(constrainedObj, path, archetypeId); } else if (constrainedObj instanceof ArchetypeSlot) { //Skip } }
/** * Check if this object node is required by occurrences * and path of nodes for which values are submitted * * @param paths a set of path of nodes for which values submitted * @return ture if this node is required */ public boolean isRequired(Set<String> paths) { if (isRequired()) { return true; } // if any submitted value for descendant nodes for (String path : paths) { if (path.startsWith(path())) { return true; } } return false; }
void replaceSlotWithFlattened(CAttribute cattr, Archetyped definition, CObject cobj) { List<CObject> children = cattr.getChildren(); if (children == null) { return; } for (int index = 0, j = children.size(); index < j; index++) { CObject child = children.get(index); if (child instanceof ArchetypeSlot) { // if the slot matches the template def children.remove(index); cobj.setPath(child.path()); children.add(index, cobj); } } }
/** Checks that the occurrences of the corresponding node in the parent conforms to the specialised node's occurrences * * @param parentNode * @param ccobj * @param errors */ private void checkSpecialisedOccurrencesCompatiblity(CObject parentNode, CObject ccobj, List<ValidationError> errors) { if (! parentNode.getOccurrences().isUpperUnbounded() && ( ccobj.getOccurrences().isUpperUnbounded() || parentNode.getOccurrences().getUpper().compareTo( ccobj.getOccurrences().getUpper()) <0)) { errors.add(new ValidationError (ErrorType.VSONCO, null, getIntervalFormalString(ccobj.getOccurrences()), ccobj.path(), getIntervalFormalString(parentNode.getOccurrences()), parentNode.path())); } }
String childRMTypeName = cobj.getRmTypeName(); childRMTypeName = removeGenericTypes(childRMTypeName); childRMTypeName, cobj.path()); errors.add(error); continue; log.debug("validating CPrimitiveObject at: " + cobj.path()); validateCPrimitiveObject((CPrimitiveObject) cobj, archetype, errors); log.debug("skipping unnecessary additional checks on " + parentRmClass); childRMTypeName, cobj.path(), rmAttrType.getSimpleName()); if (!errors.contains(error)) { errors.add(error); parentGenericTypeName, parent.path(), childRMType.getSimpleName(), cobj.path()); errors.add(error); continue; Interval<Integer> occu = cobj.getOccurrences(); if (occu != null && occu.isUpperIncluded() && occu.getUpper() > 1) { error = new ValidationError(ErrorType.VACSO, null, cobj.path()); errors.add(error); if (cobj2.getRmTypeName().equals(cobj.getRmTypeName()) && cobj.getNodeId() == null) { error = new ValidationError(ErrorType.VACSU, null,
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 String getType(CObject constrainedObj, CAttribute att) { String type; if (att != null) { if (att.getChildren() != null && !att.getChildren().isEmpty()) { type = att.getChildren().get(0).getRmTypeName(); } else { type = constrainedObj.getRmTypeName(); } } else { type = constrainedObj.getRmTypeName(); } type = convertTypeIfQuantityOrOrdinal(type); return type; }
private void loadMaps(CObject node, boolean required) { if(node != null && node.path() != null) { pathNodeMap.put(node.path(), node); nodeIdPathMap.put(node.getNodeId(), node.path()); loadMaps(child, required && node.isRequired() && attribute.isRequired());
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()); } } }
+ ", at: " + cobj.path()); if( !cobj.isRoot() ) { String path = cobj.path(); Interval<Integer> occurrences = cobj.getOccurrences(); " occurrences: " + cobj.path()); return; && occurrences.getLower().intValue() == 1) { log.warn("try to set occurrences constraint on required node: " + cobj.path()); return; } else { if(parent == null) { log.debug("parent null at " + cobj.path()); cobj.setOccurrences(newOccurrences);
if (!c1.getRmTypeName().equals(c2.getRmTypeName())) { return false; if (!c1.getOccurrences().equals(c2.getOccurrences())) { return false; if (c1.isRequired() != c2.isRequired()) { return false;
for(CObject cobj : children) { log.debug("looping children, required: " + cobj.isRequired()); if(cobj.isAllowed() && (GenerationStrategy.MAXIMUM.equals(strategy) || GenerationStrategy.MAXIMUM_EMPTY.equals(strategy) || (GenerationStrategy.MINIMUM.equals(strategy) && cobj.isRequired()))) { && "EVENT".equals(cobj.getRmTypeName())) {
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; }
if (!ccobj.getNodeId().equals(parentNode.getNodeId())) { return; // they don't have the same node id, so we don't need to check here ccobj.path(), ccobj.getRmTypeName(), parentNode.getRmTypeName(), ccobj.getNodeId())); ccobj.path(), ccobj.getRmTypeName(), parentNode.getRmTypeName(), ccobj.getNodeId(), langPrim)); ccobj.path(), ccobj.getRmTypeName(), parentNode.getRmTypeName(), ccobj.getNodeId(), trans.getValue().getLanguage().getCodeString()));
+ ", at: " + cobj.path()); String path = cobj.path(); Interval<Integer> occurrences = cobj.getOccurrences(); + " occurrences: " + cobj.path()); return; && occurrences.getLower() == 1) { log.warn("try to set occurrences constraint on required node: " + cobj.path()); return; } else { if (parent == null) { log.debug("parent null at " + cobj.path()); cobj.setOccurrences(newOccurrences);
/** * Updates the pathNodeMap with given cobj * * @param cobj */ public void updatePathNodeMap(CObject cobj) { if(cobj != null) { pathNodeMap.put(cobj.path(), cobj); } }
private static void setCardinalities(PathableVO pathableVO, CObject constrainedObj) { pathableVO.setLowerCardinality(constrainedObj.getOccurrences().getLower()); pathableVO.setUpperCardinality(constrainedObj.getOccurrences().getUpper()); }
/** * Adds a child to the children list * * @param child not null */ public void addChild(CObject child) { if(child == null) { throw new IllegalArgumentException("null child"); } children.add(child); child.setParent(this); }
private boolean hasSiblingNodeWithNodeId(CAttribute parent, String nodeId) { for (CObject cobj : parent.getChildren()) { if (nodeId.equals(cobj.getNodeId())) { return true; } } return false; }