Ejemplo n.º 1
0
 public ParameterRecord(Parameter parameter) {
   super(
       parameter.getID(),
       parameter.getDisplayName(),
       parameter.getDescription(),
       parameter.getValueAsString());
 }
Ejemplo n.º 2
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);
    }
  }