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; }
public String getMethodName() { if (node.isCoreOperator()) { return node.getType(); } if (node.isFlowPart()) { return "create"; } return node.getMethodName(); }
@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); }
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"); }
@Override public String getUseVariableName() { if (node.getOutputPorts().isEmpty()) { // empty, confluent return super.getUseVariableName() + ".out"; } return super.getUseVariableName(); }
public String getClassName() { String name = node.getClassName(); if (StringUtil.isEmpty(name)) { return "undefined_className_" + getId(); } else { return name; } }
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; }
public GenOperator(OperatorNode node) { super(node); this.node = node; for (OpePort port : node.getInputPorts()) { NodeElement cnode = port.getConnectedNode(); if (cnode != null) { incomings.add(cnode); } } }
public Object getDescription() { return node.getDescription(); }
public String getFactoryName() { if (node.isCoreOperator()) { return CORE_OP_FACTORY; } return getClassName() + "Factory"; }
public boolean isFlowPart() { return node.isFlowPart(); }
public Integer getId() { return node.getId(); }