Search in sources :

Example 1 with ServerElement

use of net.geoprism.registry.model.ServerElement in project geoprism-registry by terraframe.

the class XMLImporter method importXMLDefinitions.

@Transaction
public List<ServerElement> importXMLDefinitions(Organization organization, InputStream istream) {
    TransactionState state = TransactionState.getCurrentTransactionState();
    state.putTransactionObject("transaction-state", this.cache);
    LinkedList<ServerElement> list = new LinkedList<ServerElement>();
    try {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder dBuilder = factory.newDocumentBuilder();
        Document doc = dBuilder.parse(istream);
        list.addAll(this.createTypes(organization, doc));
        list.addAll(this.createHierarchies(organization, doc));
        list.addAll(this.createDirectedAcyclicGraphTypes(doc));
        list.addAll(this.createUndirectedGraphTypes(doc));
    } catch (ParserConfigurationException | IOException | SAXException e) {
        throw new ProgrammingErrorException(e);
    }
    return list;
}
Also used : TransactionState(com.runwaysdk.dataaccess.transaction.TransactionState) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) DocumentBuilder(javax.xml.parsers.DocumentBuilder) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) IOException(java.io.IOException) Document(org.w3c.dom.Document) ServerElement(net.geoprism.registry.model.ServerElement) LinkedList(java.util.LinkedList) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException) SAXException(org.xml.sax.SAXException) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 2 with ServerElement

use of net.geoprism.registry.model.ServerElement in project geoprism-registry by terraframe.

the class XMLImporter method createUndirectedGraphTypes.

private List<ServerElement> createUndirectedGraphTypes(Document doc) {
    LinkedList<ServerElement> list = new LinkedList<ServerElement>();
    NodeList nList = doc.getElementsByTagName("undirected-graph");
    for (int i = 0; i < nList.getLength(); i++) {
        Node nNode = nList.item(i);
        if (nNode.getNodeType() == Node.ELEMENT_NODE) {
            Element elem = (Element) nNode;
            list.add(this.createUndirectedGraphType(elem));
        }
    }
    return list;
}
Also used : NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) ServerElement(net.geoprism.registry.model.ServerElement) Element(org.w3c.dom.Element) ServerElement(net.geoprism.registry.model.ServerElement) LinkedList(java.util.LinkedList)

Example 3 with ServerElement

use of net.geoprism.registry.model.ServerElement in project geoprism-registry by terraframe.

the class XMLImporter method createDirectedAcyclicGraphTypes.

private List<ServerElement> createDirectedAcyclicGraphTypes(Document doc) {
    LinkedList<ServerElement> list = new LinkedList<ServerElement>();
    NodeList nList = doc.getElementsByTagName("dag");
    for (int i = 0; i < nList.getLength(); i++) {
        Node nNode = nList.item(i);
        if (nNode.getNodeType() == Node.ELEMENT_NODE) {
            Element elem = (Element) nNode;
            list.add(this.createDirectedAcyclicGraphType(elem));
        }
    }
    return list;
}
Also used : NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) ServerElement(net.geoprism.registry.model.ServerElement) Element(org.w3c.dom.Element) ServerElement(net.geoprism.registry.model.ServerElement) LinkedList(java.util.LinkedList)

Example 4 with ServerElement

use of net.geoprism.registry.model.ServerElement in project geoprism-registry by terraframe.

the class XMLImporter method addGroupItems.

private List<ServerElement> addGroupItems(Element root, ServerGeoObjectType superType) {
    List<ServerElement> list = new LinkedList<ServerElement>();
    NodeList nList = root.getElementsByTagName("group-item");
    for (int i = 0; i < nList.getLength(); i++) {
        Node nNode = nList.item(i);
        if (nNode.getNodeType() == Node.ELEMENT_NODE) {
            Element elem = (Element) nNode;
            String code = elem.getAttribute("code");
            LocalizedValue label = this.getLabel(elem);
            LocalizedValue description = this.getDescription(elem);
            GeoObjectType type = new GeoObjectType(code, superType.getGeometryType(), label, description, superType.isGeometryEditable(), superType.getOrganization().getCode(), adapter);
            type.setSuperTypeCode(superType.getCode());
            type.setIsPrivate(superType.getIsPrivate());
            ServerGeoObjectType result = new ServerGeoObjectTypeConverter().create(type);
            list.add(result);
            this.cache.put(code, result);
        }
    }
    return list;
}
Also used : ServerGeoObjectTypeConverter(net.geoprism.registry.conversion.ServerGeoObjectTypeConverter) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) RootGeoObjectType(net.geoprism.registry.model.RootGeoObjectType) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) GeoObjectType(org.commongeoregistry.adapter.metadata.GeoObjectType) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) ServerElement(net.geoprism.registry.model.ServerElement) Element(org.w3c.dom.Element) ServerElement(net.geoprism.registry.model.ServerElement) LinkedList(java.util.LinkedList)

Example 5 with ServerElement

use of net.geoprism.registry.model.ServerElement in project geoprism-registry by terraframe.

the class XMLImporter method createTypes.

private List<ServerElement> createTypes(Organization organization, Document doc) {
    LinkedList<ServerElement> list = new LinkedList<ServerElement>();
    NodeList nList = doc.getElementsByTagName("type");
    for (int i = 0; i < nList.getLength(); i++) {
        Node nNode = nList.item(i);
        if (nNode.getNodeType() == Node.ELEMENT_NODE) {
            Element elem = (Element) nNode;
            ServerGeoObjectType type = createServerGeoObjectType(organization, elem);
            list.add(type);
            this.cache.put(type.getCode(), type);
            this.addAttributes(elem, type);
            list.addAll(this.addGroupItems(elem, type));
        }
    }
    return list;
}
Also used : ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) ServerElement(net.geoprism.registry.model.ServerElement) Element(org.w3c.dom.Element) ServerElement(net.geoprism.registry.model.ServerElement) LinkedList(java.util.LinkedList)

Aggregations

ServerElement (net.geoprism.registry.model.ServerElement)7 LinkedList (java.util.LinkedList)6 Element (org.w3c.dom.Element)5 Node (org.w3c.dom.Node)5 NodeList (org.w3c.dom.NodeList)5 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)3 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)2 ProgrammingErrorException (com.runwaysdk.dataaccess.ProgrammingErrorException)1 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)1 TransactionState (com.runwaysdk.dataaccess.transaction.TransactionState)1 Request (com.runwaysdk.session.Request)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 Organization (net.geoprism.registry.Organization)1 ClassificationTypeTest (net.geoprism.registry.classification.ClassificationTypeTest)1 ServerGeoObjectTypeConverter (net.geoprism.registry.conversion.ServerGeoObjectTypeConverter)1 RootGeoObjectType (net.geoprism.registry.model.RootGeoObjectType)1