Examples of ModelReader


Examples of org.ofbiz.entity.model.ModelReader

        String datasourceName = (String) context.get("datasourceName");
        String entityNamePrefix = (String) context.get("entityNamePrefix");

        if (datasourceName == null) datasourceName = "localderby";

        ModelReader reader = dctx.getDelegator().getModelReader();

        try {
            if (!eomodeldFullPath.endsWith(".eomodeld")) {
                eomodeldFullPath = eomodeldFullPath + ".eomodeld";
            }

            File outdir = new File(eomodeldFullPath);
            if (!outdir.exists()) {
                outdir.mkdir();
            }
            if (!outdir.isDirectory()) {
                return ServiceUtil.returnError("eomodel Full Path is not a directory: " + eomodeldFullPath);
            }
            if (!outdir.canWrite()) {
                return ServiceUtil.returnError("eomodel Full Path is not write-able: " + eomodeldFullPath);
            }

            Set<String> entityNames = new TreeSet<String>();
            if (UtilValidate.isNotEmpty(entityPackageNameOrig)) {
                Set<String> entityPackageNameSet = FastSet.newInstance();
                entityPackageNameSet.addAll(StringUtil.split(entityPackageNameOrig, ","));

                Debug.logInfo("Exporting with entityPackageNameSet: " + entityPackageNameSet, module);

                Map<String, TreeSet<String>> entitiesByPackage = reader.getEntitiesByPackage(entityPackageNameSet, null);
                for (Map.Entry<String, TreeSet<String>> entitiesByPackageMapEntry: entitiesByPackage.entrySet()) {
                    entityNames.addAll(entitiesByPackageMapEntry.getValue());
                }
            } else if (UtilValidate.isNotEmpty(entityGroupId)) {
                Debug.logInfo("Exporting entites from the Group: " + entityGroupId, module);
                entityNames.addAll(EntityGroupUtil.getEntityNamesByGroup(entityGroupId, dctx.getDelegator(), false));
            } else {
                entityNames.addAll(reader.getEntityNames());
            }
            Debug.logInfo("Exporting the following entities: " + entityNames, module);

            // remove all view-entity
            Iterator<String> filterEntityNameIter = entityNames.iterator();
            while (filterEntityNameIter.hasNext()) {
                String entityName = filterEntityNameIter.next();
                ModelEntity modelEntity = reader.getModelEntity(entityName);
                if (modelEntity instanceof ModelViewEntity) {
                    filterEntityNameIter.remove();
                }
            }

            // write the index.eomodeld file
            Map<String, Object> topLevelMap = FastMap.newInstance();
            topLevelMap.put("EOModelVersion", "\"2.1\"");
            List<Map<String, Object>> entitiesMapList = FastList.newInstance();
            topLevelMap.put("entities", entitiesMapList);
            for (String entityName: entityNames) {
                Map<String, Object> entitiesMap = FastMap.newInstance();
                entitiesMapList.add(entitiesMap);
                entitiesMap.put("className", "EOGenericRecord");
                entitiesMap.put("name", entityName);
            }
            UtilPlist.writePlistFile(topLevelMap, eomodeldFullPath, "index.eomodeld", true);

            // write each <EntityName>.plist file
            for (String curEntityName: entityNames) {
                ModelEntity modelEntity = reader.getModelEntity(curEntityName);
                UtilPlist.writePlistFile(modelEntity.createEoModelMap(entityNamePrefix, datasourceName, entityNames, reader), eomodeldFullPath, curEntityName +".plist", true);
            }

            return ServiceUtil.returnSuccess("Exported eomodeld file for " + entityNames.size() + " entities to: " + eomodeldFullPath);
        } catch (UnsupportedEncodingException e) {
View Full Code Here

Examples of org.ofbiz.entity.model.ModelReader

            request.setAttribute("_ERROR_MESSAGE_", errMsg);
            Debug.logWarning("[updateGeneric] The delegator object was not found in the request, please check the control servlet init.", module);
            return "error";
        }

        ModelReader reader = delegator.getModelReader();
        ModelEntity entity = null;

        try {
            entity = reader.getModelEntity(entityName);
        } catch (GenericEntityException e) {
            Debug.logError(e, module);
        }

        String updateMode = request.getParameter("UPDATE_MODE");
View Full Code Here

Examples of org.slim3.datastore.json.ModelReader

     *           
     * @return model array
     */
    @SuppressWarnings("unchecked")
    public M[] jsonToModels(String json, int maxDepth){
        JsonArrayReader ar = new JsonArrayReader(json, new ModelReader() {
            @Override
            public <T> T read(JsonReader reader, Class<T> modelClass, int maxDepth,
                    int currentDepth) {
                return invokeJsonToModel(
                    Datastore.getModelMeta(modelClass),
View Full Code Here

Examples of org.slim3.datastore.json.ModelReader

     *            the current depth
     *           
     * @return model
     */
    protected M jsonToModel(String json, int maxDepth, int currentDepth){
        return jsonToModel(new JsonRootReader(json, new ModelReader() {
            @Override
            public <T> T read(JsonReader reader, Class<T> modelClass, int maxDepth,
                    int currentDepth) {
                return invokeJsonToModel(
                    Datastore.getModelMeta(modelClass),
View Full Code Here

Examples of org.slim3.datastore.json.ModelReader

     *            the current depth
     *           
     * @return model
     */
    public M jsonToModel(String json, int maxDepth, int currentDepth){
        return jsonToModel(new JsonRootReader(json, new ModelReader() {
            public <T> T read(JsonReader reader, Class<T> modelClass, int maxDepth,
                    int currentDepth) {
                return invokeJsonToModel(
                    Datastore.getModelMeta(modelClass),
                    reader, maxDepth, currentDepth + 1);
View Full Code Here

Examples of org.slim3.datastore.json.ModelReader

     *           
     * @return model array
     */
    @SuppressWarnings("unchecked")
    public M[] jsonToModels(String json, int maxDepth){
        JsonArrayReader ar = new JsonArrayReader(json, new ModelReader() {
            @Override
            public <T> T read(JsonReader reader, Class<T> modelClass, int maxDepth,
                    int currentDepth) {
                return invokeJsonToModel(
                    Datastore.getModelMeta(modelClass),
View Full Code Here

Examples of org.slim3.datastore.json.ModelReader

     *            the current depth
     *           
     * @return model
     */
    protected M jsonToModel(String json, int maxDepth, int currentDepth){
        return jsonToModel(new JsonRootReader(json, new ModelReader() {
            @Override
            public <T> T read(JsonReader reader, Class<T> modelClass, int maxDepth,
                    int currentDepth) {
                return invokeJsonToModel(
                    Datastore.getModelMeta(modelClass),
View Full Code Here

Examples of org.slim3.datastore.json.ModelReader

     *
     * @return model array
     */
    @SuppressWarnings("unchecked")
    public M[] jsonToModels(String json, int maxDepth) {
        JsonArrayReader ar = new JsonArrayReader(json, new ModelReader() {
            @Override
            public <T> T read(JsonReader reader, Class<T> modelClass,
                    int maxDepth, int currentDepth) {
                return invokeJsonToModel(
                    Datastore.getModelMeta(modelClass),
View Full Code Here

Examples of org.slim3.datastore.json.ModelReader

     *            the current depth
     *
     * @return model
     */
    protected M jsonToModel(String json, int maxDepth, int currentDepth) {
        return jsonToModel(new JsonRootReader(json, new ModelReader() {
            @Override
            public <T> T read(JsonReader reader, Class<T> modelClass,
                    int maxDepth, int currentDepth) {
                return invokeJsonToModel(
                    Datastore.getModelMeta(modelClass),
View Full Code Here

Examples of org.tinyuml.ui.commands.ModelReader

  private void openModel() {
    JFileChooser fileChooser = new JFileChooser();
    fileChooser.setDialogTitle(getResourceString("dialog.openmodel.title"));
    if (fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
      try {
        ModelReader fileLoader = new ModelReader(fileChooser.getSelectedFile(),
          elementFactory);
        umlModel.reset();
        tabbedPane.removeAll();
        for (UmlModelElement elem : fileLoader.getElements()) {
          umlModel.addElement(elem);
        }
        createEditor(fileLoader.getDiagrams().get(0));
      } catch (IOException ex) {
        JOptionPane.showMessageDialog(this, ex.getMessage(),
          getResourceString("error.readfile.title"),
          JOptionPane.ERROR_MESSAGE);
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.