Search in sources :

Example 1 with PrefixMapper

use of com.evolveum.midpoint.schema.xjc.PrefixMapper in project midpoint by Evolveum.

the class StepSchemaConstants method run.

@Override
public boolean run(Outline outline, Options opt, ErrorHandler errorHandler) throws Exception {
    Model model = outline.getModel();
    JDefinedClass schemaConstants = model.codeModel._class(CLASS_NAME);
    //creating namespaces
    List<FieldBox<String>> namespaces = new ArrayList<FieldBox<String>>();
    for (PrefixMapper prefix : PrefixMapper.values()) {
        namespaces.add(new FieldBox("NS_" + prefix.getNamespaceName(), prefix.getNamespace()));
    }
    Collections.sort(namespaces);
    for (FieldBox<String> field : namespaces) {
        JFieldVar var = createNSFieldDefinition(outline, schemaConstants, field.getFieldName(), field.getValue());
        getNamespaceFields().put(field.getValue(), var);
    }
    //creating qnames
    List<FieldBox<QName>> fields = new ArrayList<FieldBox<QName>>();
    Map<QName, CElementInfo> map = model.getElementMappings(null);
    Set<Map.Entry<QName, CElementInfo>> set = map.entrySet();
    for (Map.Entry<QName, CElementInfo> entry : set) {
        QName qname = entry.getKey();
        CElementInfo info = entry.getValue();
        String fieldName = ProcessorUtils.fieldPrefixedUnderscoredUpperCase(info.getSqueezedName(), qname);
        fields.add(new FieldBox(fieldName, qname));
    }
    //sort field by name and create qname definitions in class
    Collections.sort(fields);
    for (FieldBox<QName> field : fields) {
        JFieldVar var = namespaceFields.get(field.getValue().getNamespaceURI());
        if (var != null) {
            createQNameDefinition(outline, schemaConstants, field.getFieldName(), var, field.getValue());
        } else {
            ProcessorUtils.createPSFField(outline, schemaConstants, field.getFieldName(), field.getValue());
        }
    }
    return true;
}
Also used : PrefixMapper(com.evolveum.midpoint.schema.xjc.PrefixMapper) QName(javax.xml.namespace.QName) CElementInfo(com.sun.tools.xjc.model.CElementInfo) Model(com.sun.tools.xjc.model.Model)

Aggregations

PrefixMapper (com.evolveum.midpoint.schema.xjc.PrefixMapper)1 CElementInfo (com.sun.tools.xjc.model.CElementInfo)1 Model (com.sun.tools.xjc.model.Model)1 QName (javax.xml.namespace.QName)1