private boolean isObjectReference(XSAnnotation annotation) { Element objRefAnnotationElement = SchemaProcessorUtil.getAnnotationElement(annotation, A_OBJECT_REFERENCE); return (objRefAnnotationElement != null); }
Element indexableElement = SchemaProcessorUtil.getAnnotationElement(annotation, A_INDEXED); if (indexableElement != null) { Boolean indexable = XmlTypeConverter.toJavaValue(indexableElement, Boolean.class); Element matchingRuleElement = SchemaProcessorUtil.getAnnotationElement(annotation, A_MATCHING_RULE); if (matchingRuleElement != null) { QName matchingRule = XmlTypeConverter.toJavaValue(matchingRuleElement, QName.class); Element valueEnumerationRefElement = SchemaProcessorUtil.getAnnotationElement(annotation, A_VALUE_ENUMERATION_REF); if (valueEnumerationRefElement != null) { String oid = valueEnumerationRefElement.getAttribute(PrismConstants.ATTRIBUTE_OID_LOCAL_NAME);
private boolean isResourceObject(XSAnnotation annotation) { // annotation: resourceObject if (SchemaProcessorUtil.getAnnotationElement(annotation, MidPointConstants.RA_RESOURCE_OBJECT) != null) { return true; } // annotation: accountType DEPRECATED if (SchemaProcessorUtil.getAnnotationElement(annotation, MidPointConstants.RA_ACCOUNT) != null) { // <accountType> implies <resourceObject> ... at least for now (compatibility) return true; } return false; }
private boolean testAnnotationAppinfo(XSAnnotation annotation) { Element appinfo = SchemaProcessorUtil.getAnnotationElement(annotation, new QName(W3C_XML_SCHEMA_NS_URI, "appinfo")); if (appinfo != null) { return true; } return false; }
public static <T> T getAnnotationConverted(XSAnnotation annotation, QName qname, Class<T> type) throws SchemaException { Element element = getAnnotationElement(annotation, qname); if (element == null) { return null; } String textContent = element.getTextContent(); if (textContent == null || textContent.isEmpty()) { return null; } return XmlTypeConverter.toJavaValue(element, type); }
public static QName getAnnotationQName(XSAnnotation annotation, QName qname) { Element element = getAnnotationElement(annotation, qname); if (element == null) { return null; } return DOMUtil.getQNameValue(element); }
private boolean isAccountObject(XSAnnotation annotation) { if (annotation == null || annotation.getAnnotation() == null) { return false; } Element accountType = SchemaProcessorUtil.getAnnotationElement(annotation, MidPointConstants.RA_ACCOUNT); if (accountType != null) { return true; } return false; }
/** * Parses "marker" boolean annotation. This means: * no element: false * empty element: true * non-empty element: parse element content as boolean */ public static Boolean getAnnotationBooleanMarker(XSAnnotation annotation, QName qname) throws SchemaException { Element element = getAnnotationElement(annotation, qname); if (element == null) { return null; } String textContent = element.getTextContent(); if (textContent == null || textContent.isEmpty()) { return true; } return XmlTypeConverter.toJavaValue(element, Boolean.class); }
private MutablePrismPropertyDefinition createResourceAttributeDefinition(QName elementName, QName typeName, PrismContext prismContext, XSAnnotation annotation) throws SchemaException { ResourceAttributeDefinitionImpl attrDef = new ResourceAttributeDefinitionImpl(elementName, typeName, prismContext); // nativeAttributeName Element nativeAttrElement = SchemaProcessorUtil.getAnnotationElement(annotation, MidPointConstants.RA_NATIVE_ATTRIBUTE_NAME); String nativeAttributeName = nativeAttrElement == null ? null : nativeAttrElement.getTextContent(); if (!StringUtils.isEmpty(nativeAttributeName)) { attrDef.setNativeAttributeName(nativeAttributeName); } // frameworkAttributeName Element frameworkAttrElement = SchemaProcessorUtil.getAnnotationElement(annotation, MidPointConstants.RA_FRAMEWORK_ATTRIBUTE_NAME); String frameworkAttributeName = frameworkAttrElement == null ? null : frameworkAttrElement.getTextContent(); if (!StringUtils.isEmpty(frameworkAttributeName)) { attrDef.setFrameworkAttributeName(frameworkAttributeName); } // returnedByDefault attrDef.setReturnedByDefault(SchemaProcessorUtil.getAnnotationBoolean(annotation, MidPointConstants.RA_RETURNED_BY_DEFAULT_NAME)); return attrDef; }
private boolean isPropertyContainer(XSElementDecl xsElementDecl) { Element annoElement = SchemaProcessorUtil.getAnnotationElement(xsElementDecl.getAnnotation(), A_PROPERTY_CONTAINER); if (annoElement != null) { return true; } return isPropertyContainer(xsElementDecl.getType()); }
private String getDefaultNamespace(XSType xsType) { Element annoElement = SchemaProcessorUtil.getAnnotationElement(xsType.getAnnotation(), A_DEFAULT_NAMESPACE); if (annoElement != null) { return annoElement.getTextContent(); } if (xsType.getBaseType() != null && !xsType.getBaseType().equals(xsType)) { return getDefaultNamespace(xsType.getBaseType()); } return null; }
private void extractDocumentation(Definition definition, XSAnnotation annotation) { if (annotation == null) { return; } Element documentationElement = SchemaProcessorUtil.getAnnotationElement(annotation, DOMUtil.XSD_DOCUMENTATION_ELEMENT); if (documentationElement != null) { // The documentation may be HTML-formatted. Therefore we want to // keep the formatting and tag names String documentationText = DOMUtil.serializeElementContent(documentationElement); definition.toMutable().setDocumentation(documentationText); } }
private ResourceAttributeDefinition getAnnotationReference(XSAnnotation annotation, QName qname, ObjectClassComplexTypeDefinition objectClass) throws SchemaException { Element element = SchemaProcessorUtil.getAnnotationElement(annotation, qname); if (element != null) { String reference = element.getTextContent(); if (reference == null || reference.isEmpty()) { // Compatibility reference = element.getAttribute("ref"); } if (reference != null && !reference.isEmpty()) { QName referenceItemName = DOMUtil.resolveQName(element, reference); PrismPropertyDefinition definition = objectClass.findPropertyDefinition(ItemName.fromQName(referenceItemName)); if (definition == null) { throw new SchemaException("The annotation "+qname+" in "+objectClass+" is pointing to "+referenceItemName+" which does not exist"); } if (definition instanceof ResourceAttributeDefinition) { return (ResourceAttributeDefinition) definition; } else { throw new SchemaException("The annotation "+qname+" in "+objectClass+" is pointing to "+referenceItemName+" which is not an attribute, it is "+definition); } } } return null; }
/** * Returns true if provides XSD type is a property container. It looks for * annotations. */ private boolean isPropertyContainer(XSType xsType) { Element annoElement = SchemaProcessorUtil.getAnnotationElement(xsType.getAnnotation(), A_PROPERTY_CONTAINER); if (annoElement != null) { return true; } if (xsType.getBaseType() != null && !xsType.getBaseType().equals(xsType)) { return isPropertyContainer(xsType.getBaseType()); } return false; }
private void setMultiplicity(MutableItemDefinition itemDef, XSParticle particle, XSAnnotation annotation, boolean topLevel) { if (topLevel || particle == null) { itemDef.setMinOccurs(0); Element maxOccursAnnotation = SchemaProcessorUtil.getAnnotationElement(annotation, A_MAX_OCCURS); if (maxOccursAnnotation != null) { String maxOccursString = maxOccursAnnotation.getTextContent(); int maxOccurs = XsdTypeMapper.multiplicityToInteger(maxOccursString); itemDef.setMaxOccurs(maxOccurs); } else { itemDef.setMaxOccurs(-1); } } else { // itemDef.setMinOccurs(particle.getMinOccurs()); // itemDef.setMaxOccurs(particle.getMaxOccurs()); itemDef.setMinOccurs(particle.getMinOccurs().intValue()); itemDef.setMaxOccurs(particle.getMaxOccurs().intValue()); } }
public static boolean hasAnnotation(XSType xsType, QName annotationElementName) { if (xsType.getName() == null) { return false; } Element annotationElement = getAnnotationElement(xsType.getAnnotation(), annotationElementName); if (annotationElement != null) { return true; } if (xsType.getBaseType() != null && !xsType.getBaseType().equals(xsType)) { return hasAnnotation(xsType.getBaseType(), annotationElementName); } return false; }
for (XSFacet facet : enumerations) { String value = facet.getValue().value; Element descriptionE = SchemaProcessorUtil.getAnnotationElement(facet.getAnnotation(), SCHEMA_DOCUMENTATION); Element appInfo = SchemaProcessorUtil.getAnnotationElement(facet.getAnnotation(), SCHEMA_APP_INFO); Element valueE = null;
Element nativeAttrElement = SchemaProcessorUtil.getAnnotationElement(annotation, MidPointConstants.RA_NATIVE_OBJECT_CLASS); String nativeObjectClass = nativeAttrElement == null ? null : nativeAttrElement.getTextContent(); ocDef.setNativeObjectClass(nativeObjectClass); Element kindElement = SchemaProcessorUtil.getAnnotationElement(annotation, MidPointConstants.RA_KIND); if (kindElement != null) { String kindString = kindElement.getTextContent(); Element intentElement = SchemaProcessorUtil.getAnnotationElement(annotation, MidPointConstants.RA_INTENT); if (intentElement != null) { intent = intentElement.getTextContent(); Element account = SchemaProcessorUtil.getAnnotationElement(annotation, MidPointConstants.RA_ACCOUNT); if (account != null && !defaultInAKind) { String defaultValue = account.getAttribute("default"); Element accountTypeElement = SchemaProcessorUtil.getAnnotationElement(annotation, MidPointConstants.RA_ACCOUNT_TYPE); if (accountTypeElement != null) { String accountType = accountTypeElement.getTextContent();
Element processing = SchemaProcessorUtil.getAnnotationElement(annotation, A_PROCESSING); if (processing != null) { itemDef.setProcessing(ItemProcessing.findByValue(processing.getTextContent())); Element deprecatedSince = SchemaProcessorUtil.getAnnotationElement(annotation, A_DEPRECATED_SINCE); if (deprecatedSince != null) { itemDef.setDeprecatedSince(deprecatedSince.getTextContent()); Element plannedRemoval = SchemaProcessorUtil.getAnnotationElement(annotation, A_PLANNED_REMOVAL); if (plannedRemoval != null) { itemDef.setPlannedRemoval(plannedRemoval.getTextContent()); Element attributeDisplayName = SchemaProcessorUtil.getAnnotationElement(annotation, A_DISPLAY_NAME); if (attributeDisplayName != null) { itemDef.setDisplayName(attributeDisplayName.getTextContent()); Element displayOrderElement = SchemaProcessorUtil.getAnnotationElement(annotation, A_DISPLAY_ORDER); if (displayOrderElement != null) { Integer displayOrder = DOMUtil.getIntegerValue(displayOrderElement); Element help = SchemaProcessorUtil.getAnnotationElement(annotation, A_HELP); if (help != null) { itemDef.setHelp(help.getTextContent());
QName typeName = new QName(xsType.getTargetNamespace(), xsType.getName()); QName primaryElementName = elementName; Element objRefAnnotationElement = SchemaProcessorUtil.getAnnotationElement(annotation, A_OBJECT_REFERENCE); boolean hasExplicitPrimaryElementName = (objRefAnnotationElement != null Element targetTypeAnnotationElement = SchemaProcessorUtil.getAnnotationElement(annotation, A_OBJECT_REFERENCE_TARGET_TYPE); if (targetTypeAnnotationElement != null