Search in sources :

Example 1 with XMLInput

use of com.axelor.data.xml.XMLInput in project axelor-open-suite by axelor.

the class AppLoaderExportServiceImpl method createMetaModelInput.

protected XMLInput createMetaModelInput(AppDataLoader dataLoader, boolean relationalInput) throws ClassNotFoundException {
    XMLInput xmlInput = createXmlInput(dataLoader);
    Mapper modelMapper = Mapper.of(Class.forName(dataLoader.getMetaModel().getFullName()));
    String nodeName = getBindNodeName(xmlInput.getRoot());
    XMLBind xmlBind = new XMLBind();
    xmlBind.setTypeName(dataLoader.getMetaModel().getFullName());
    xmlBind.setNode(nodeName);
    if (!CollectionUtils.isEmpty(dataLoader.getSearchMetaFieldSet())) {
        xmlBind.setSearch(getMetaSearchFields(modelMapper, dataLoader));
        xmlBind.setUpdate(true);
    }
    if (relationalInput) {
        xmlBind.setCreate(false);
    }
    xmlBind.setBindings(getMetaFieldBinding(modelMapper, dataLoader, relationalInput));
    List<XMLBind> rootBindings = new ArrayList<XMLBind>();
    rootBindings.add(xmlBind);
    xmlInput.setBindings(rootBindings);
    return xmlInput;
}
Also used : Mapper(com.axelor.db.mapper.Mapper) ArrayList(java.util.ArrayList) XMLInput(com.axelor.data.xml.XMLInput) XMLBind(com.axelor.data.xml.XMLBind)

Example 2 with XMLInput

use of com.axelor.data.xml.XMLInput in project axelor-open-suite by axelor.

the class AppLoaderExportServiceImpl method createJsonModelInput.

protected XMLInput createJsonModelInput(AppDataLoader dataLoader, boolean relationalInput) {
    XMLInput xmlInput = createXmlInput(dataLoader);
    Map<String, Object> jsonFieldMap = MetaStore.findJsonFields(dataLoader.getModelName());
    fixTargetName(jsonFieldMap);
    String nodeName = getBindNodeName(xmlInput.getRoot());
    XMLBindJson xmlBindJson = new XMLBindJson();
    xmlBindJson.setNode(nodeName);
    xmlBindJson.setJsonModel(dataLoader.getModelName());
    if (!CollectionUtils.isEmpty(dataLoader.getSearchJsonFieldSet())) {
        xmlBindJson.setSearch(getJsonSearchFields(dataLoader, jsonFieldMap));
        xmlBindJson.setUpdate(true);
    }
    if (relationalInput) {
        xmlBindJson.setCreate(false);
    }
    xmlBindJson.setBindings(geJsonFieldBinding(jsonFieldMap, dataLoader, relationalInput));
    List<XMLBind> rootBindings = new ArrayList<XMLBind>();
    rootBindings.add(xmlBindJson);
    xmlInput.setBindings(rootBindings);
    return xmlInput;
}
Also used : XMLBindJson(com.axelor.data.xml.XMLBindJson) ArrayList(java.util.ArrayList) XMLInput(com.axelor.data.xml.XMLInput) XMLBind(com.axelor.data.xml.XMLBind)

Example 3 with XMLInput

use of com.axelor.data.xml.XMLInput in project axelor-open-suite by axelor.

the class AppLoaderExportServiceImpl method createXmlInput.

protected XMLInput createXmlInput(AppDataLoader dataLoader) {
    XMLInput xmlInput = new XMLInput();
    String modelName = dataLoader.getModelName();
    xmlInput.setFileName(modelName + ".xml");
    String dasherizeModel = Inflector.getInstance().dasherize(modelName);
    xmlInput.setRoot(dasherizeModel + "s");
    return xmlInput;
}
Also used : XMLInput(com.axelor.data.xml.XMLInput)

Aggregations

XMLInput (com.axelor.data.xml.XMLInput)3 XMLBind (com.axelor.data.xml.XMLBind)2 ArrayList (java.util.ArrayList)2 XMLBindJson (com.axelor.data.xml.XMLBindJson)1 Mapper (com.axelor.db.mapper.Mapper)1