示例#1
0
 public ParameterRecord(Parameter parameter) {
   super(
       parameter.getID(),
       parameter.getDisplayName(),
       parameter.getDescription(),
       parameter.getValueAsString());
 }
示例#2
0
  public OperationRecord(Operation operation) {

    // name
    this.nameID.setId(operation.getID());
    this.nameID.setDisplayName(operation.getDisplayName());
    this.nameID.setDescription(operation.getDescription());

    // category
    this.categoryName = operation.getCategoryName();
    this.categoryColor = operation.getCategoryColor();

    // module
    if (operation.getDefinition().getCategory().getModule() != null) {
      this.moduleName = operation.getDefinition().getCategory().getModule().getModuleName();
    }

    // parameters
    for (Parameter parameter : operation.getParameters()) {
      this.parameters.put(parameter.getID(), new ParameterRecord(parameter));
    }

    // inputs
    for (DataBinding binding : operation.getBindings()) {
      InputDefinition inputDefinition = operation.getDefinition().getInput(binding.getName());
      String displayName =
          inputDefinition.isMulti()
              ? inputDefinition.getDisplayName(binding.getName())
              : inputDefinition.getDisplayName();
      this.inputs.put(
          binding.getName(),
          new InputRecord(
              binding.getName(), displayName, inputDefinition.getDescription(), binding.getData()));
    }

    // source code
    // TODO get it from ResultMessage when it becomes available
    this.sourceCode = "not yet available";
  }
示例#3
0
  private void createOperations() {
    for (OperationType operationType : sessionType.getOperation()) {
      String operationSessionId = operationType.getId();

      // check for unique id
      if (operationRecords.containsKey(operationSessionId)) {
        logger.warn("duplicate operation id: " + operationSessionId);
        continue;
      }

      OperationRecord operationRecord = new OperationRecord();

      // name id
      operationRecord.setNameID(createNameID(operationType.getName()));

      // category
      operationRecord.setCategoryName(operationType.getCategory());
      String colorString = operationType.getCategoryColor();
      if (colorString != null) {
        operationRecord.setCategoryColor(Color.decode(colorString));
      }

      // module
      operationRecord.setModule(operationType.getModule());

      // parameters
      for (ParameterType parameterType : operationType.getParameter()) {
        operationRecord.addParameter(
            parameterType.getName().getId(),
            parameterType.getName().getDisplayName(),
            parameterType.getName().getDescription(),
            parameterType.getValue());
      }

      // source code
      String sourceCodeFileName = operationType.getSourceCodeFile();
      if (sourceCodeFileName != null && !sourceCodeFileName.isEmpty()) {
        String sourceCode = null;
        try {
          sourceCode = getSourceCode(sourceCodeFileName);
        } catch (Exception e) {
          logger.warn("could not load source code from " + sourceCodeFileName);
        }

        // might be null, is ok
        operationRecord.setSourceCode(sourceCode);
      }

      // update names, category from the current version of the tool
      OperationDefinition currentTool;
      currentTool =
          Session.getSession()
              .getApplication()
              .getOperationDefinitionBestMatch(
                  operationRecord.getNameID().getID(),
                  operationRecord.getModule(),
                  operationRecord.getCategoryName());
      if (currentTool != null) {
        operationRecord.getNameID().setDisplayName(currentTool.getDisplayName());
        operationRecord.getNameID().setDescription(currentTool.getDescription());
        if (currentTool.getCategory().getModule() != null) {
          operationRecord.setModule(currentTool.getCategory().getModule().getModuleName());
        }
        operationRecord.setCategoryName(currentTool.getCategoryName());
        operationRecord.setCategoryColor(currentTool.getCategory().getColor());

        for (ParameterRecord parameterRecord : operationRecord.getParameters()) {
          Parameter currentParameter =
              currentTool.getParameter(parameterRecord.getNameID().getID());
          if (currentParameter != null) {
            parameterRecord.getNameID().setDisplayName(currentParameter.getDisplayName());
            parameterRecord.getNameID().setDescription(currentParameter.getDescription());
          }
        }
      }

      // store the operation record
      operationRecords.put(operationSessionId, operationRecord);
      operationTypes.put(operationRecord, operationType);
    }
  }
示例#4
0
 public void addParameter(Parameter parameter) {
   this.parameters.put(parameter.getID(), new ParameterRecord(parameter));
 }