コード例 #1
0
ファイル: ChainTypeImpl.java プロジェクト: GlearDev/nuxeo
 @Override
 public OperationDocumentation getDocumentation() throws OperationException {
   OperationDocumentation doc = new OperationDocumentation(id);
   doc.label = id;
   doc.requires = contribution.getRequires();
   doc.category = contribution.getCategory();
   doc.setAliases(contribution.getAliases());
   OperationChainContribution.Operation[] operations = contribution.getOps();
   doc.operations = operations;
   doc.since = contribution.getSince();
   if (doc.requires.length() == 0) {
     doc.requires = null;
   }
   if (doc.label.length() == 0) {
     doc.label = doc.id;
   }
   doc.description = contribution.getDescription();
   doc.params = contribution.getParams();
   // load signature
   if (operations.length != 0) {
     // Fill signature with first inputs of the first operation and
     // related outputs of last operation
     // following the proper automation path
     ArrayList<String> result = getSignature(operations);
     doc.signature = result.toArray(new String[result.size()]);
   } else {
     doc.signature = new String[] {"void", "void"};
   }
   return doc;
 }
コード例 #2
0
 public AutomationInfo(AutomationService service) {
   ops = service.getDocumentation();
   // build a map for easy lookup
   Map<String, OperationDocumentation> map = new HashMap<String, OperationDocumentation>();
   for (OperationDocumentation doc : ops) {
     map.put(doc.id, doc);
   }
   chains = new ArrayList<OperationDocumentation>();
   for (OperationChain chain : service.getOperationChains()) {
     OperationDocumentation doc = new OperationDocumentation(chain.getId());
     doc.description = chain.getDescription();
     doc.category = "Chain";
     doc.label = doc.id;
     doc.params = Collections.emptyList();
     // compute chain signature
     List<OperationParameters> ops = chain.getOperations();
     if (ops.isEmpty()) {
       doc.signature = new String[] {"void", "void"};
     } else if (ops.size() == 1) {
       OperationDocumentation opdoc = map.get(ops.get(0).id());
       doc.signature = opdoc.signature;
     } else {
       ArrayList<String[]> sigs = new ArrayList<String[]>();
       for (OperationParameters o : ops) {
         sigs.add(map.get(o.id()).signature);
       }
       String[] head = sigs.get(0);
       ArrayList<String> rs = new ArrayList<String>();
       for (int i = 0; i < head.length; i += 2) {
         String in = head[i];
         String out = head[i + 1];
         List<String> result = new ArrayList<String>();
         checkPath(out, sigs, 1, result);
         for (String r : result) {
           rs.add(in);
           rs.add(r);
         }
       }
       doc.signature = rs.toArray(new String[rs.size()]);
     }
     chains.add(doc);
   }
 }