Exemplo n.º 1
0
  @SuppressWarnings("rawtypes")
  public static void initDevPackage(DEVPackage devPackage) {

    Gson gson = new Gson();
    if (devPackage != null && devPackage.getOwnedElements() != null) {
      List ownedElements = (List) devPackage.getOwnedElements();

      /*
      Entity entityManageApi = new Entity();
      entityManageApi.setName(devPackage.getName() + "EntityManageApi");
      entityManageApi.set_parent(new StarUmlReference(devPackage.get_id()));
      entityManageApi.setTemplatePath(devPackage.getTemplatePath());
      entityManageApi.setStereotype("Api");
      devPackage.getOwnedElements().add(entityManageApi);*/

      for (int i = 0; i < ownedElements.size(); i++) {
        Entity entity = null;
        Object aa = ownedElements.get(i);
        if (aa.getClass().toString().contains("Entity")) {
          entity = (Entity) aa;
        } else {
          LinkedHashMap data = (LinkedHashMap) ownedElements.get(i);
          String type = (String) data.get("_type");
          String id = (String) data.get("_id");
          String stereotype = (String) data.get("stereotype");
          if (type.equals("UMLClass")) {
            String eleJson = gson.toJson(data);
            entity = gson.fromJson(eleJson, Entity.class);
          }
        }

        if (entity != null) {
          entity.collectExtraAttributes();
          entity.setDevPackage(devPackage);
          entity.setTemplatePath(devPackage.getTemplatePath());
          StarUmlObjectContainer.addObject(entity.get_id(), entity);
          StarUmlObjectContainer.addObjectByName(entity.getName(), entity);
          devPackage.addEntity(entity.get_id(), entity);
          StarUmlReference ref = new StarUmlReference(devPackage.get_id());
          entity.set_parent(ref);
          ownedElements.set(i, entity);

          // auto generate ApiManage Entity
          /*
          if (entity.getStereotype() != null && entity.getStereotype().equals("Entity")) {
              EntityOperation entityManageOp = new EntityOperation(entityManageApi);
              entityManageOp.setName("manage" + entity.getName());
              entityManageApi.addOperation(entityManageOp);
              entityManageApi.addDepend(entity.getName(), entity);
          }*/
        }
      }
      //	devPackage.normalizeTypes();
    }
  }
Exemplo n.º 2
0
  public String[] exportDotNetCode(String path) {
    path = path + "/" + projectName + "/";
    Iterator<Entry<String, Entity>> entityIter = entities.entrySet().iterator();

    String sqlMap = "";

    String csprojectContent = "";

    while (entityIter.hasNext()) {
      Entry<String, Entity> entry = entityIter.next();
      Entity val = entry.getValue();

      val.setTemplatePath(templatePath);
      val.setDevPackage(this);
      /*
      PersistEntityDotNet persistDN = new PersistEntityDotNet(val);
      persistDN.setTemplatePath(templatePath);
      PersistEntityDotNet.projectName = projectName;
      if ("Api".equals(val.getStereotype())) {
          csprojectContent += persistDN.genOperations(path);
      } else if ("Entity".equals(val.getStereotype())) {
          csprojectContent += persistDN.genEntity(path);
          csprojectContent += persistDN.genMapper(path);
          csprojectContent += persistDN.genControl(path);
          csprojectContent += persistDN.genResponse(path);

          sqlMap += MessageFormat.format("\t<sqlMap resource=\"Mapper/{0}.xml\"/>\r\n", persistDN.getBaseEntity().getName());
      } else if (val.getStereotype() != null && val.getStereotype().startsWith("Html")) {
      } else if (val.getStereotype() == null || !val.getStereotype().startsWith("Ele")) {
          csprojectContent += persistDN.genItem(path);
          csprojectContent += persistDN.genResponse(path);
          sqlMap += MessageFormat.format("\t<sqlMap resource=\"Mapper/{0}.xml\"/>\r\n", persistDN.getBaseEntity().getName());
      }

      */
    }

    String[] s = new String[2];
    s[0] = sqlMap;
    s[1] = csprojectContent;
    return s;
  }