Java Code Examples for org.apache.ws.commons.schema.XmlSchemaAppInfo#getMarkup()

The following examples show how to use org.apache.ws.commons.schema.XmlSchemaAppInfo#getMarkup() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DidSchemaParser.java    From secure-data-service with Apache License 2.0 6 votes vote down vote up
/**
 * Parse an annotation for keyfields and add to a map
 */
private Map<String, String> parseAnnotationForKeyField(XmlSchemaAnnotation annotation) {
    Map<String, String> keyField = new HashMap<String, String>();

    XmlSchemaAppInfo appInfo = getAppInfo(annotation);
    if (appInfo != null) {
        NodeList nodes = appInfo.getMarkup();
        for (int nodeIdx = 0; nodeIdx < nodes.getLength(); nodeIdx++) {
            Node node = nodes.item(nodeIdx);
            if (node instanceof Element) {
                String key = node.getLocalName().trim();
                String value = node.getFirstChild().getNodeValue().trim();

                if (key.equals(REF_TYPE) || key.equals(KEY_FIELD_NAME)) {
                    keyField.put(key, value);
                }
            }
        }
    }
    return keyField;
}
 
Example 2
Source File: DidSchemaParser.java    From secure-data-service with Apache License 2.0 6 votes vote down vote up
/**
 * Parse an annotation for recordType annotation
 */
private String parseAnnotationForRecordType(XmlSchemaAnnotation annotation) {
    String recordType = null;
    XmlSchemaAppInfo appInfo = getAppInfo(annotation);
    if (appInfo != null) {
        NodeList nodes = appInfo.getMarkup();
        for (int nodeIdx = 0; nodeIdx < nodes.getLength(); nodeIdx++) {
            Node node = nodes.item(nodeIdx);
            if (node instanceof Element) {
                String key = node.getLocalName().trim();
                String value = node.getFirstChild().getNodeValue().trim();

                if (key.equals(RECORD_TYPE)) {
                    recordType = value;
                    break;
                }
            }
        }
    }
    return recordType;
}
 
Example 3
Source File: DidSchemaParser.java    From secure-data-service with Apache License 2.0 6 votes vote down vote up
/**
 * Parse an annotation for naturalKeys annotation
 */
private String parseAnnotationForNaturalKeys(XmlSchemaAnnotation annotation) {
    String naturalKeys = null;

    XmlSchemaAppInfo appInfo = getAppInfo(annotation);
    if (appInfo != null) {
        NodeList nodes = appInfo.getMarkup();
        for (int nodeIdx = 0; nodeIdx < nodes.getLength(); nodeIdx++) {
            Node node = nodes.item(nodeIdx);
            if (node instanceof Element) {
                String key = node.getLocalName().trim();
                String value = node.getFirstChild().getNodeValue().trim();

                if (key.equals("naturalKeys")) {
                    naturalKeys = value;
                    break;
                }
            }
        }
    }
    return naturalKeys;
}
 
Example 4
Source File: CobolAnnotations.java    From legstar-core2 with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * XSD elements are annotated with COBOL markup that we extract here.
 * 
 * @param xsdElement the XSD element
 * @return the COBOL markup
 */
private static Element getCobolXsdAnnotations(XmlSchemaElement xsdElement) {
    XmlSchemaAnnotation annotation = xsdElement.getAnnotation();
    if (annotation == null || annotation.getItems().size() == 0) {
        throw new IllegalArgumentException("Xsd element of type "
                + xsdElement.getSchemaType().getQName()
                + " at line " + xsdElement.getLineNumber()
                + " does not have COBOL annotations");
    }

    XmlSchemaAppInfo appinfo = (XmlSchemaAppInfo) annotation.getItems()
            .get(0);
    if (appinfo.getMarkup() == null) {
        throw new IllegalArgumentException("Xsd element of type "
                + xsdElement.getSchemaType().getQName()
                + " does not have any markup in its annotations");
    }
    Node node = null;
    boolean found = false;
    for (int i = 0; i < appinfo.getMarkup().getLength(); i++) {
        node = appinfo.getMarkup().item(i);
        if (node instanceof Element
                && node.getLocalName().equals(CobolMarkup.ELEMENT)
                && node.getNamespaceURI().equals(CobolMarkup.NS)) {
            found = true;
            break;
        }
    }
    if (!found) {
        throw new IllegalArgumentException("Xsd element of type "
                + xsdElement.getSchemaType().getQName()
                + " at line " + xsdElement.getLineNumber()
                + " does not have any COBOL annotations");
    }
    return (Element) node;
}
 
Example 5
Source File: DidSchemaParser.java    From secure-data-service with Apache License 2.0 5 votes vote down vote up
/**
 * Parse an annotation for DidRefSource data
 */
private DidRefSource parseAnnotationForRef(XmlSchemaAnnotation annotation) {
    DidRefSource refSource = null;

    boolean applyKeyFields = false;
    String refType = null;

    XmlSchemaAppInfo appInfo = getAppInfo(annotation);
    if (appInfo != null) {
        // get applyKeyFields and refType from appInfo
        NodeList nodes = appInfo.getMarkup();
        for (int nodeIdx = 0; nodeIdx < nodes.getLength(); nodeIdx++) {
            Node node = nodes.item(nodeIdx);
            if (node instanceof Element) {

                String key = node.getLocalName().trim();
                String value = node.getFirstChild().getNodeValue().trim();

                if (key.equals(APPLY_KEY_FIELDS)) {
                    if (value.equals("true")) {
                        applyKeyFields = true;
                    }
                } else if (key.equals(REF_TYPE)) {
                    refType = value;
                }
            }
        }
        if (applyKeyFields && refType != null) {
            refSource = new DidRefSource();
            refSource.setEntityType(refType);
        }
    }

    return refSource;
}