예제 #1
0
    public String getReturnTypeName() {
      if ("stop".equals(node.getType())) {
        return null;
      }
      if (node.isFlowPart()) {
        return getCachedClassName(
            getFactoryName() + "." + StringUtil.getSimpleName(getClassName()));
      }

      String type = getMethodName();
      String className = getCachedClassName(getFactoryName() + "." + StringUtil.toFirstUpper(type));

      String nodeType = node.getType();
      if ("restructure".equals(nodeType)
          || "extend".equals(nodeType)
          || "project".equals(nodeType)
          || "checkpoint".equals(nodeType)) {
        OpePort port = node.getOutputPort();
        String modelClass = getCachedClassName(getModelClassName(port));
        return className + "<" + modelClass + ">";
      }
      if ("empty".equals(nodeType) || "confluent".equals(nodeType)) {
        String modelClass = findModelClass(node);
        modelClass = getCachedClassName(modelClass);
        return className + "<" + modelClass + ">";
      }

      return className;
    }
예제 #2
0
 public String getMethodName() {
   if (node.isCoreOperator()) {
     return node.getType();
   }
   if (node.isFlowPart()) {
     return "create";
   }
   return node.getMethodName();
 }
예제 #3
0
 @Override
 public String createVariableName() {
   String name;
   if (node.isFlowPart()) {
     name = StringUtil.getSimpleName(getFactoryName());
     name = StringUtil.removeEnds(name, "Factory");
   } else {
     name = node.getMethodName();
   }
   return StringUtil.toFirstLower(name);
 }
예제 #4
0
  private void appendDescribe(StringBuilder sb) {
    sb.append("\t@Override\n");
    sb.append("\tpublic void describe() {\n");

    Map<Integer, GenNode> map = new HashMap<Integer, GenNode>();
    for (JobPort port : frame.getInputPorts()) {
      GenImporter gen = new GenImporter(port);
      map.put(port.getId(), gen);
      nodeMap.put(port, gen);
    }

    List<GenOperator> opeList = new ArrayList<GenOperator>();
    for (NodeElement node : diagram.getContents()) {
      if (node instanceof OperatorNode) {
        OperatorNode operator = (OperatorNode) node;
        GenOperator gop = new GenOperator(operator);
        opeList.add(gop);
        getFactoryVariableName(gop.getFactoryName(), gop.isFlowPart());
        nodeMap.put(node, gop);
        for (OpePort port : operator.getPorts()) {
          nodeMap.put(port, new GenPort(port));
        }
      }
    }

    appendDescribeVariable(sb);

    for (int i = 0; ; ) {
      if (opeList.isEmpty()) {
        break;
      }
      if (i >= opeList.size()) {
        i = 0;
      }
      GenOperator node = opeList.get(i);
      if (node.complete(map)) {
        appendNode(sb, node, map);
        map.put(node.getId(), node);
        opeList.remove(node);
      } else {
        i++;
      }
    }

    sb.append("\n");
    for (JobPort port : frame.getOutputPorts()) {
      appendExporter(sb, port);
    }

    sb.append("\t}\n");
  }
예제 #5
0
 @Override
 public String getUseVariableName() {
   if (node.getOutputPorts().isEmpty()) { // empty, confluent
     return super.getUseVariableName() + ".out";
   }
   return super.getUseVariableName();
 }
예제 #6
0
 public String getClassName() {
   String name = node.getClassName();
   if (StringUtil.isEmpty(name)) {
     return "undefined_className_" + getId();
   } else {
     return name;
   }
 }
예제 #7
0
    public void appendArgsTo(StringBuilder sb) {
      List<String> args = new ArrayList<String>();
      for (OpePort port : node.getInputPorts()) {
        NodeElement cnode = port.getConnectedNode();
        GenNode gen = nodeMap.get(cnode);
        String varName = (gen != null) ? gen.getUseVariableName() : "null";
        args.add(varName);
      }
      for (Connection c : node.getIncomings()) {
        NodeElement cnode = c.getOpposite(node);
        GenNode gen = nodeMap.get(cnode);
        String varName = (gen != null) ? gen.getUseVariableName() : "null";
        args.add(varName);
      }
      for (OpeParameter param : node.getParameterList()) {
        args.add(getQualifiedValue(param.getClassName(), param.getValue()));
      }
      String nodeType = node.getType();
      if ("restructure".equals(nodeType)
          || "extend".equals(nodeType)
          || "project".equals(nodeType)) {
        OpePort port = node.getOutputPort();
        String modelClass = getModelClassName(port);
        args.add(getQualifiedValue("java.lang.Class", modelClass));
      } else if ("empty".equals(nodeType)) {
        String modelClass = findModelClass(node);
        args.add(getQualifiedValue("java.lang.Class", modelClass));
      }

      if ("confluent".equals(nodeType)) {
        switch (args.size()) {
          case 2:
          case 3:
          case 4:
            break;
          default:
            sb.append(getCachedClassName("java.util.Arrays"));
            sb.append(".asList(");
            StringUtil.mkString(sb, args);
            sb.append(")");
            return;
        }
      }
      StringUtil.mkString(sb, args);
    }
  /**
   * データモデルの種類を推測する.
   *
   * @return データモデルの種類
   */
  public GuessDataModelType guessDataModelType() {
    List<GuessDataModelType> guess = null;
    if (modelNode instanceof OpePort) {
      OpePort port = (OpePort) modelNode;
      NodeElement parent = port.getParent();
      if (parent instanceof OperatorNode) {
        OperatorNode operator = (OperatorNode) parent;
        GuessDataModelType type = operator.guessDataModelType(port);
        if (type != null) {
          if (type.isDecision()) {
            return type;
          }
          guess = new ArrayList<GuessDataModelType>();
          guess.add(type);
        }
      }
    }

    for (SiblingDataModelTreeElement c : children) {
      GuessDataModelType type = c.guessDataModelType();
      if (type != null) {
        if (type.isDecision()) {
          return type;
        }
        if (guess == null) {
          guess = new ArrayList<GuessDataModelType>();
        }
        guess.add(type);
      }
    }

    if (guess != null) {
      Collections.sort(
          guess,
          new Comparator<GuessDataModelType>() {
            @Override
            public int compare(GuessDataModelType o1, GuessDataModelType o2) {
              return o2.getGuessLevel() - o1.getGuessLevel();
            }
          });
      return guess.get(0);
    }

    return null;
  }
예제 #9
0
 public GenOperator(OperatorNode node) {
   super(node);
   this.node = node;
   for (OpePort port : node.getInputPorts()) {
     NodeElement cnode = port.getConnectedNode();
     if (cnode != null) {
       incomings.add(cnode);
     }
   }
 }
예제 #10
0
 public Object getDescription() {
   return node.getDescription();
 }
예제 #11
0
 public String getFactoryName() {
   if (node.isCoreOperator()) {
     return CORE_OP_FACTORY;
   }
   return getClassName() + "Factory";
 }
예제 #12
0
 public boolean isFlowPart() {
   return node.isFlowPart();
 }
예제 #13
0
 public Integer getId() {
   return node.getId();
 }