Search in sources :

Example 1 with Tdesignate

use of org.eclipse.kura.core.configuration.metatype.Tdesignate in project kura by eclipse.

the class XmlJavaMetadataMapper method unmarshal.

@SuppressWarnings("unchecked")
@Override
public <T> T unmarshal(Document doc) {
    Element metadata = doc.getDocumentElement();
    Tmetadata tMetadata = parseMetadataAttributes(metadata);
    NodeList metadataChilds = metadata.getChildNodes();
    Element[] metadataChildsArray = getElementNodes(metadataChilds);
    for (Element node : metadataChildsArray) {
        String localName = node.getNodeName();
        if (localName.equals("OCD")) {
            Tocd tocd = parseOCD(node);
            tMetadata.setOCD(tocd);
        } else if (localName.equals("Designate")) {
            Tdesignate tDesignate = parseDesignate(node);
            tMetadata.setDesignate(tDesignate);
        }
    }
    return (T) tMetadata;
}
Also used : Tmetadata(org.eclipse.kura.core.configuration.metatype.Tmetadata) Tdesignate(org.eclipse.kura.core.configuration.metatype.Tdesignate) Element(org.w3c.dom.Element) NodeList(org.w3c.dom.NodeList) Tocd(org.eclipse.kura.core.configuration.metatype.Tocd)

Example 2 with Tdesignate

use of org.eclipse.kura.core.configuration.metatype.Tdesignate in project kura by eclipse.

the class XmlJavaMetadataMapper method parseDesignate.

private Tdesignate parseDesignate(Element designate) {
    String pid = designate.getAttribute(METADATA_DESIGNATE_PID);
    String factoryPid = designate.getAttribute(METADATA_DESIGNATE_FACTORY_PID);
    String bundle = designate.getAttribute(METADATA_DESIGNATE_BUNDLE);
    Boolean optional = Boolean.parseBoolean(designate.getAttribute(METADATA_DESIGNATE_OPTIONAL));
    Boolean merge = Boolean.parseBoolean(designate.getAttribute(METADATA_DESIGNATE_MERGE));
    Tdesignate tDesignate = new Tdesignate();
    if (!pid.trim().isEmpty()) {
        tDesignate.setPid(pid);
    }
    if (!factoryPid.trim().isEmpty()) {
        tDesignate.setFactoryPid(factoryPid);
    }
    if (!bundle.trim().isEmpty()) {
        tDesignate.setBundle(bundle);
    }
    tDesignate.setOptional(optional);
    tDesignate.setMerge(merge);
    NodeList objectsChilds = designate.getChildNodes();
    Element[] objectsChildElements = getElementNodes(objectsChilds);
    for (Element node : objectsChildElements) {
        String localName = node.getNodeName();
        if (localName.equals(METADATA_DESIGNATE_OBJECT)) {
            // parse Object
            Tobject tObject = parseObject(node);
            tDesignate.setObject(tObject);
        }
    }
    return tDesignate;
}
Also used : Tdesignate(org.eclipse.kura.core.configuration.metatype.Tdesignate) NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element) Tobject(org.eclipse.kura.core.configuration.metatype.Tobject)

Aggregations

Tdesignate (org.eclipse.kura.core.configuration.metatype.Tdesignate)2 Element (org.w3c.dom.Element)2 NodeList (org.w3c.dom.NodeList)2 Tmetadata (org.eclipse.kura.core.configuration.metatype.Tmetadata)1 Tobject (org.eclipse.kura.core.configuration.metatype.Tobject)1 Tocd (org.eclipse.kura.core.configuration.metatype.Tocd)1