private CObject getCChildCObject(CAttribute att) { CObject childCObject = null; if ((att != null) && (att.getChildren() != null) && !att.getChildren().isEmpty()) { childCObject = att.getChildren().get(0); } return childCObject; }
private void removeArchetypeSlots(CAttribute cattr) { if(cattr == null) { return; } // TODO verify slots by RM types for(Iterator<CObject> it = cattr.getChildren().iterator(); it.hasNext();) { CObject cobj = it.next(); if(cobj instanceof ArchetypeSlot) { it.remove(); log.debug("archetype_slot removed from attribute " + cattr.getRmAttributeName()); } } }
CComplexObject ccobj = (CComplexObject) cobj; for(CAttribute cattr : ccobj.getAttributes()) { path = cattr.path(); cattr.setPath(prefix + path); for(Iterator<CObject> it = cattr.getChildren().iterator(); it.hasNext();) {
/** * Return true if this attribute is required * or there is any submitted input value for its descendants * * @return true if 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(childNodePathBase())) { return true; } } return false; }
/** Checks that the existence of the parent archetype's corresponding attribute is conformant * with the child archetype's attribute in the sense of VSANCE error validation * * @param cattr * @param attrInParentArchetype * @param errors */ private void checkSpecialisedAttributeNodeExistenceConformance( CAttribute cattr, CAttribute attrInParentArchetype, List<ValidationError> errors) { if ((cattr.getExistence() == Existence.OPTIONAL && (attrInParentArchetype.getExistence() == Existence.REQUIRED || attrInParentArchetype.getExistence() == Existence.NOT_ALLOWED)) || (cattr.getExistence() == Existence.REQUIRED && attrInParentArchetype.getExistence() == Existence.NOT_ALLOWED) || (cattr.getExistence() == Existence.NOT_ALLOWED && attrInParentArchetype.getExistence() != Existence.NOT_ALLOWED) ) { errors.add(new ValidationError(ErrorType.VSANCE, null, cattr.getExistence().toString(), cattr.path(), attrInParentArchetype.getExistence(), attrInParentArchetype.path())); } }
if(cattr.getChildren() == null || cattr.getChildren().isEmpty()) { throw new FlatteningException( "failed to set value constraint, null/empty children list"); for(CObject child : cattr.getChildren()) { String childType = child.getRmTypeName(); for(String type : includedTypes) { cattr.removeAllChildren(); for(CObject child : newChildrenList) { cattr.addChild(child); cattr.addChild(child); + cattr.getChildren().size() + "child(s)");
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()); } } }
if (attribute.getExistence().equals( CAttribute.Existence.NOT_ALLOWED)) { continue; if (attribute.getChildren() == null) { continue; // no child for (CObject child : attribute.getChildren()) { loadMaps(child, required && node.isRequired() && attribute.isRequired());
VALUE, Existence.REQUIRED); } else if (cattr.getChildren().size() == 1) { CObject child = cattr.getChildren().get(0); String rmType = childCCObj.getRmTypeName(); if (DV_TEXT.equals(rmType) || DV_CODED_TEXT.equals(rmType)) { cattr.removeChild(child); String path = cattr.path() + "/" + VALUE; CComplexObject valueObj = CComplexObject.createSingleRequired(path, DV_TEXT); CAttribute valueAttr = CSingleAttribute.createRequired(path, VALUE); cattr.addChild(valueObj); valueObj.addAttribute(valueAttr); valueAttr.addChild(cpo); CCodePhrase ccp = new CCodePhrase(path, occurrences, null, cattr, null, null, codePhrase, null); cattr.addChild(ccp);
newline(out); indent(indent, out); out.write(cattribute.getRmAttributeName()); if (!CAttribute.Existence.REQUIRED.equals(cattribute.getExistence())) { out.write(" "); printExistence(cattribute.getExistence(), out); if (cattribute instanceof CMultipleAttribute) { CMultipleAttribute cma = (CMultipleAttribute) cattribute; List<CObject> children = cattribute.getChildren(); out.write(" matches {"); if(children == null || children.size() == 0) { || !(children.get(0) instanceof CPrimitiveObject)) { newline(out); for (CObject cobject : cattribute.getChildren()) { printCObject(cobject, indent + 1, out);
String parentNodePathInParentArchetype = getExpectedPathInParentArchetype(cattr.parentNodePath(), childSpecialisationDepth-1); CAttribute attrInParentArchetype = null; if (parentNodePathInParentArchetype != null) { attrInParentArchetype = ((CComplexObject) parentNodeInParentArchetype).getAttribute(cattr.getRmAttributeName()); } else { if (cattr.getChildren() != null) { for (CObject cobj : cattr.getChildren()) { log.debug("-----"); log.debug(cobj.getRmTypeName() + " " +cobj.path()); if (cattr.getRmAttributeName().equals("value")) {
printString("rm_attribute_name", cattribute.getRmAttributeName(), attributes); if(cattribute.getExistence().equals(CAttribute.Existence.REQUIRED)) { lower = 1; upper = 1; } else if(cattribute.getExistence().equals(CAttribute.Existence.OPTIONAL)) { lower = 0; upper = 1; printString("upper", Integer.toString(upper), existence); if(!cattribute.isAnyAllowed()) { List<CObject> children = cattribute.getChildren(); for (CObject cobject : cattribute.getChildren()) { printCObject(cobject, attributes);
String rmAttrName = cattr.getRmAttributeName(); Class rmAttrType = rmAttrs.get(rmAttrName); rmAttrName, cattr.path(), parent.getRmTypeName()); } else { rmAttrName, parent.getRmTypeName(), cattr.path()); if (cattr.getChildren() == null) { return; for (CObject cobj : cattr.getChildren()) { for (CObject cobj2 : cattr.getChildren()) { if (cobj == cobj2) { continue; getIntervalFormalString(cardinalityInterval), getIntervalFormalString(cobj.getOccurrences()), cattr.path()); for (CObject cobj2 : cattr.getChildren()) { if (cobj == cobj2) { continue; for (CObject cobj2 : cattr.getChildren()) { if (cobj == cobj2) { continue;
if(cattr.isAllowed() && (GenerationStrategy.MAXIMUM.equals(strategy) || GenerationStrategy.MAXIMUM_EMPTY.equals(strategy) || (GenerationStrategy.MINIMUM.equals(strategy) && cattr.isRequired()))) { Object attrValue; String path = cattr.path(); attrValue = createAttribute(cattr, archetype, archetypeMap, extraValues, strategy); valueMap.put(cattr.getRmAttributeName(), attrValue); valueMap.put(cattr.getRmAttributeName(), attrValue);
/** * Checks if a specific attribute constraint identified by its rmAttributeName. * @param rmAttributeName the attribute name of the attribute to be retrieved * @return the attribute or null if no specific constraint with that rmAttributeName exists */ public boolean hasAttribute(String rmAttributeName) { if (attributes == null) return false; for (CAttribute attribute : attributes) { if (attribute.getRmAttributeName().equals(rmAttributeName)) { return true; } } return false; }
CAttribute cc2A = cc2.getAttribute(cc1A.getRmAttributeName()); if (cc2A == null) { return false; if (!cc1A.getExistence().toString().equals(cc2A.getExistence().toString())) { return false; if (cc1A.isRequired() != cc2A.isRequired()) { return false; if (cc1A.isAllowed() != cc2A.isAllowed()) { return false;
private void fillArchetypeSlot(Archetype parentArchetype, Archetype archetype, String path, String name) throws FlatteningException { String archetypeId = archetype.getArchetypeId().toString(); CComplexObject root = archetype.getDefinition(); if (parentArchetype != null) { // TODO has a quick-fix for the following path syntax // "/activities[at0001 and name/value='Medication activity']/description" // WILL NOT WORK IN OTHER CASES!! int hybridStart = path.indexOf(" and name/value='"); if (hybridStart > 0) { int index = path.indexOf("]"); path = path.substring(0, hybridStart) + path.substring(index); log.debug("hybrid path detected, converted physical path: " + path); } CAttribute attribute = getParentAttribute(parentArchetype, path); if (attribute == null) { throw new FlatteningException("CAttribute not found at " + path); } removeArchetypeSlots(attribute); root.setNodeId(archetypeId); String pathSegment = archetypeId; if (name != null) { checkSiblingNodeIdAndName(attribute, archetypeId, name); pathSegment = namedNodeSegment(archetypeId, name); } setPathPrefixOnCObjectTree(root, attribute.path() + "[" + pathSegment + "]"); attribute.addChild(root); } }
if (cattr.getChildren() == null || cattr.getChildren().isEmpty()) { throw new FlatteningException( "failed to set value constraint, null/empty children list"); for (CObject child : cattr.getChildren()) { String childType = child.getRmTypeName(); for (String type : includedTypes) { cattr.removeAllChildren(); for (CObject child : newChildrenList) { cattr.addChild(child); cattr.addChild(child); + cattr.getChildren().size() + "child(s)");