Search in sources :

Example 16 with CaseSensitiveXMLElement

use of com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement in project navajo by Dexels.

the class GenerateXSD method createSpecialMessageType.

private CaseSensitiveXMLElement createSpecialMessageType(String specialMessageTypeName, String adapterName) throws Exception {
    CaseSensitiveXMLElement messageType = new CaseSensitiveXMLElement();
    messageType.setName("xs:complexType");
    messageType.setAttribute("name", specialMessageTypeName);
    CaseSensitiveXMLElement choice2 = new CaseSensitiveXMLElement("xs:choice");
    choice2.setAttribute("minOccurs", "0");
    choice2.setAttribute("maxOccurs", "unbounded");
    messageType.addChild(choice2);
    // Add inherited elements
    for (int i = 0; i < inherited.length; i++) {
        CaseSensitiveXMLElement x = new CaseSensitiveXMLElement("xs:element");
        x.setAttribute("ref", inherited[i]);
        choice2.addChild(x);
    }
    CaseSensitiveXMLElement m = new CaseSensitiveXMLElement("xs:element");
    m.setAttribute("name", "message");
    m.setAttribute("type", specialMessageTypeName);
    choice2.addChild(m);
    CaseSensitiveXMLElement attr = new CaseSensitiveXMLElement();
    attr.setName("xs:attribute");
    attr.setAttribute("use", "required");
    attr.setAttribute("name", "name");
    attr.setAttribute("type", "xs:string");
    messageType.addChild(attr);
    attr = new CaseSensitiveXMLElement();
    attr.setName("xs:attribute");
    attr.setAttribute("name", "type");
    attr.setAttribute("type", "xs:string");
    messageType.addChild(attr);
    attr = new CaseSensitiveXMLElement();
    attr.setName("xs:attribute");
    attr.setAttribute("name", "condition");
    attr.setAttribute("type", "xs:string");
    messageType.addChild(attr);
    attr = new CaseSensitiveXMLElement();
    attr.setName("xs:attribute");
    attr.setAttribute("name", "mode");
    attr.setAttribute("type", "xs:string");
    messageType.addChild(attr);
    attr = new CaseSensitiveXMLElement();
    attr.setName("xs:attribute");
    attr.setAttribute("name", "index");
    attr.setAttribute("type", "xs:string");
    messageType.addChild(attr);
    CaseSensitiveXMLElement insertedadapters = new CaseSensitiveXMLElement("adapters:insertedadapters");
    choice2.addChild(insertedadapters);
    generateSetters(messageType, choice2, adapterName, false);
    generateMethods(choice2, adapterName);
    return messageType;
}
Also used : CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement)

Example 17 with CaseSensitiveXMLElement

use of com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement in project navajo by Dexels.

the class GenerateXSD method createAdapterXSD.

private XMLElement createAdapterXSD(String adapterName, CaseSensitiveXMLElement parent) throws Exception {
    String specialMessageTypeName = adapterName + "MessageType";
    CaseSensitiveXMLElement basic = new CaseSensitiveXMLElement("xs:element");
    basic.setAttribute("name", "map." + adapterName);
    CaseSensitiveXMLElement type = new CaseSensitiveXMLElement("xs:complexType");
    basic.addChild(type);
    CaseSensitiveXMLElement choice = new CaseSensitiveXMLElement("xs:choice");
    choice.setAttribute("minOccurs", "0");
    choice.setAttribute("maxOccurs", "unbounded");
    type.addChild(choice);
    // Add inherited elements
    for (int i = 0; i < inherited.length; i++) {
        CaseSensitiveXMLElement x = new CaseSensitiveXMLElement("xs:element");
        x.setAttribute("ref", inherited[i]);
        choice.addChild(x);
    }
    // Add Special message type reference.
    CaseSensitiveXMLElement m = new CaseSensitiveXMLElement("xs:element");
    m.setAttribute("name", "message");
    m.setAttribute("type", specialMessageTypeName);
    choice.addChild(m);
    CaseSensitiveXMLElement specialMessage = createSpecialMessageType(specialMessageTypeName, adapterName);
    parent.addChild(specialMessage);
    // Add adapters:insertedadapters
    CaseSensitiveXMLElement insertedadapters = new CaseSensitiveXMLElement("adapters:insertedadapters");
    choice.addChild(insertedadapters);
    generateSetters(type, choice, adapterName, true);
    CaseSensitiveXMLElement conditionAttr = new CaseSensitiveXMLElement("xs:attribute");
    conditionAttr.setAttribute("name", "condition");
    conditionAttr.setAttribute("type", "xs:string");
    type.addChild(conditionAttr);
    generateMethods(choice, adapterName);
    return basic;
}
Also used : CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement)

Example 18 with CaseSensitiveXMLElement

use of com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement in project navajo by Dexels.

the class GenerateXSD method generateXSD.

public String generateXSD() throws Exception {
    CaseSensitiveXMLElement xml = new CaseSensitiveXMLElement();
    InputStreamReader fis = new InputStreamReader(getClass().getClassLoader().getResourceAsStream("basenavascript.xsd"));
    xml.parseFromReader(fis);
    fis.close();
    MapMetaData mmd = MapMetaData.getInstance();
    Set<String> maps = mmd.getMapDefinitions();
    Iterator<String> all = maps.iterator();
    while (all.hasNext()) {
        String mappie = all.next();
        if (!mappie.equals("__empty__")) {
            XMLElement x = createAdapterXSD(mappie, xml);
            xml.addChild(x);
        }
    }
    ArrayList<XMLElement> tags = new ArrayList<XMLElement>();
    findTags(xml, "adapters:insertedadapters", tags);
    for (int i = 0; i < tags.size(); i++) {
        XMLElement x = tags.get(i);
        XMLElement parent = x.getParent();
        // <xs:element ref="map.sqlquery"/>
        all = maps.iterator();
        while (all.hasNext()) {
            String mappie = all.next();
            if (!mappie.equals("__empty__")) {
                CaseSensitiveXMLElement replace = new CaseSensitiveXMLElement("xs:element");
                replace.setAttribute("ref", "map." + mappie);
                parent.addChild(replace);
            }
        }
        parent.removeChild(x);
    }
    StringWriter sb = new StringWriter();
    xml.write(sb);
    return sb.toString();
}
Also used : CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) InputStreamReader(java.io.InputStreamReader) StringWriter(java.io.StringWriter) ArrayList(java.util.ArrayList) MapMetaData(com.dexels.navajo.mapping.compiler.meta.MapMetaData) CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) XMLElement(com.dexels.navajo.document.nanoimpl.XMLElement)

Example 19 with CaseSensitiveXMLElement

use of com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement in project navajo by Dexels.

the class GeoEdge method createElement.

@Override
public XMLElement createElement() {
    XMLElement c = new CaseSensitiveXMLElement("LineString");
    c.addTagKeyValue("extrude", "0");
    c.addTagKeyValue("altitudeMode", "clampToGround");
    c.addTagKeyValue("tesselate", "0");
    c.addTagKeyValue("coordinates", toString());
    return c;
}
Also used : CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) XMLElement(com.dexels.navajo.document.nanoimpl.XMLElement)

Example 20 with CaseSensitiveXMLElement

use of com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement in project navajo by Dexels.

the class GeoPolygonGroup method dumpMe.

private void dumpMe(String filename, List<GeoPolygon> pp) {
    List<XMLElement> debugList = new ArrayList<XMLElement>();
    for (GeoPolygon geoPoly : pp) {
        debugList.addAll(geoPoly.createPlaceMarkList());
    }
    XMLElement kml = new CaseSensitiveXMLElement("kml");
    XMLElement doc = new CaseSensitiveXMLElement("Document");
    kml.addChild(doc);
    for (XMLElement element : debugList) {
        doc.addChild(element);
    }
    try {
        writeElement(filename, kml);
    } catch (IOException e) {
        logger.error("Error: ", e);
    }
}
Also used : CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) ArrayList(java.util.ArrayList) IOException(java.io.IOException) CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) XMLElement(com.dexels.navajo.document.nanoimpl.XMLElement)

Aggregations

CaseSensitiveXMLElement (com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement)53 XMLElement (com.dexels.navajo.document.nanoimpl.XMLElement)49 IOException (java.io.IOException)10 InputStreamReader (java.io.InputStreamReader)7 FileReader (java.io.FileReader)5 HashMap (java.util.HashMap)5 File (java.io.File)3 FileInputStream (java.io.FileInputStream)3 APIException (com.dexels.navajo.article.APIException)2 Message (com.dexels.navajo.document.Message)2 Property (com.dexels.navajo.document.Property)2 BufferedReader (java.io.BufferedReader)2 InputStream (java.io.InputStream)2 PrintWriter (java.io.PrintWriter)2 Reader (java.io.Reader)2 StringReader (java.io.StringReader)2 StringWriter (java.io.StringWriter)2 ArrayList (java.util.ArrayList)2 XMLParseException (com.dexels.navajo.document.nanoimpl.XMLParseException)1 AdapterFieldDependency (com.dexels.navajo.mapping.compiler.meta.AdapterFieldDependency)1