Ejemplo n.º 1
0
 @Override
 protected void tearDown() throws Exception {
   JAI.getDefaultInstance().setTileScheduler(jaiTileScheduler);
   GPF.getDefaultInstance().getOperatorSpiRegistry().removeOperatorSpi(OP2_SPI);
   GPF.getDefaultInstance().getOperatorSpiRegistry().removeOperatorSpi(OP3_SPI);
   GPF.getDefaultInstance().getOperatorSpiRegistry().removeOperatorSpi(OUTPUT_OP_SPI);
 }
Ejemplo n.º 2
0
  @Override
  protected void setUp() throws Exception {
    context = new GraphCommandLineContext();
    clTool = new CommandLineTool(context);
    GPF.getDefaultInstance().getOperatorSpiRegistry().addOperatorSpi(OP2_SPI);
    GPF.getDefaultInstance().getOperatorSpiRegistry().addOperatorSpi(OP3_SPI);
    GPF.getDefaultInstance().getOperatorSpiRegistry().addOperatorSpi(OUTPUT_OP_SPI);

    JAI jai = JAI.getDefaultInstance();
    jaiTileScheduler = jai.getTileScheduler();
    SunTileScheduler tileScheduler = new SunTileScheduler();
    tileScheduler.setParallelism(Runtime.getRuntime().availableProcessors());
    jai.setTileScheduler(tileScheduler);
  }
Ejemplo n.º 3
0
  ReprojectionDialog(
      boolean orthorectify, final String title, final String helpID, AppContext appContext) {
    super(appContext, title, ID_APPLY_CLOSE, helpID);
    form = new ReprojectionForm(getTargetProductSelector(), orthorectify, appContext);

    final OperatorSpi operatorSpi =
        GPF.getDefaultInstance().getOperatorSpiRegistry().getOperatorSpi(OPERATOR_NAME);

    ParameterUpdater parameterUpdater = new ReprojectionParameterUpdater();

    OperatorParameterSupport parameterSupport =
        new OperatorParameterSupport(operatorSpi.getOperatorClass(), null, null, parameterUpdater);
    OperatorMenu operatorMenu =
        new OperatorMenu(
            this.getJDialog(), operatorSpi.getOperatorClass(), parameterSupport, helpID);

    getJDialog().setJMenuBar(operatorMenu.createDefaultMenu());
  }
Ejemplo n.º 4
0
  private Map<String, Object> convertParameterMap(
      String operatorName, Map<String, String> parameterMap) throws ValidationException {
    HashMap<String, Object> parameters = new HashMap<String, Object>();
    PropertyContainer container =
        ParameterDescriptorFactory.createMapBackedOperatorPropertyContainer(
            operatorName, parameters);
    // explicitly set default values for putting them into the backing map
    container.setDefaultValues();

    // handle xml parameters
    Object parametersObject = metadataResourceEngine.getVelocityContext().get("parameterFile");
    if (parametersObject instanceof Resource) {
      Resource paramatersResource = (Resource) parametersObject;
      if (paramatersResource.isXml()) {
        OperatorSpiRegistry operatorSpiRegistry = GPF.getDefaultInstance().getOperatorSpiRegistry();
        OperatorSpi operatorSpi = operatorSpiRegistry.getOperatorSpi(operatorName);
        Class<? extends Operator> operatorClass = operatorSpi.getOperatorClass();
        DefaultDomConverter domConverter =
            new DefaultDomConverter(operatorClass, new ParameterDescriptorFactory());

        DomElement parametersElement = createDomElement(paramatersResource.getContent());
        try {
          domConverter.convertDomToValue(parametersElement, container);
        } catch (ConversionException e) {
          String msgPattern = "Can not convert XML parameters for operator '%s'";
          throw new RuntimeException(String.format(msgPattern, operatorName));
        }
      }
    }

    for (Entry<String, String> entry : parameterMap.entrySet()) {
      String paramName = entry.getKey();
      String paramValue = entry.getValue();
      final Property property = container.getProperty(paramName);
      if (property != null) {
        property.setValueFromText(paramValue);
      } else {
        throw new RuntimeException(
            String.format("Parameter '%s' is not known by operator '%s'", paramName, operatorName));
      }
    }
    return parameters;
  }
Ejemplo n.º 5
0
  RadiometryDialog(String alias, AppContext appContext, String title, String helpId) {
    super(
        appContext,
        title,
        ID_APPLY_CLOSE,
        helpId,
        TargetProductSelectorModel.createEnvisatTargetProductSelectorModel());
    this.alias = alias;
    final OperatorSpi operatorSpi =
        GPF.getDefaultInstance().getOperatorSpiRegistry().getOperatorSpi(alias);

    parameterSupport = new OperatorParameterSupport(operatorSpi.getOperatorClass());
    form =
        new RadiometryForm(
            appContext, operatorSpi, parameterSupport.getPopertySet(), getTargetProductSelector());
    OperatorMenu operatorMenu =
        new OperatorMenu(
            this.getJDialog(), operatorSpi.getOperatorClass(), parameterSupport, helpId);
    getJDialog().setJMenuBar(operatorMenu.createDefaultMenu());
  }
  public NestSingleTargetProductDialog(
      String operatorName, AppContext appContext, String title, String helpID) {
    super(operatorName, appContext, title, helpID);

    final OperatorSpi operatorSpi =
        GPF.getDefaultInstance().getOperatorSpiRegistry().getOperatorSpi(operatorName);
    if (operatorSpi == null) {
      throw new IllegalArgumentException("operatorName " + operatorName);
    }

    opUI = operatorSpi.createOperatorUI();

    addParameters(operatorSpi, appContext, helpID);

    getJDialog().setMinimumSize(new Dimension(450, 450));
    getJDialog().setIconImage(ResourceUtils.esaPlanetIcon.getImage());

    statusLabel = new JLabel("");
    statusLabel.setForeground(new Color(255, 0, 0));
    this.getJDialog().getContentPane().add(statusLabel, BorderLayout.NORTH);
  }
Ejemplo n.º 7
0
 static {
   GPF.getDefaultInstance().getOperatorSpiRegistry().loadOperatorSpis();
 }
Ejemplo n.º 8
0
  private void runGraph() throws Exception {
    final OperatorSpiRegistry operatorSpiRegistry =
        GPF.getDefaultInstance().getOperatorSpiRegistry();

    Map<String, String> templateVariables = getRawParameterMap();

    Map<String, String> sourceNodeIdMap = getSourceNodeIdMap();
    templateVariables.putAll(sourceNodeIdMap);
    // todo - use Velocity and the current Velocity context for reading the graph XML! (nf,
    // 20120610)
    Graph graph = readGraph(commandLineArgs.getGraphFilePath(), templateVariables);
    Node lastNode = graph.getNode(graph.getNodeCount() - 1);
    SortedMap<String, String> sourceFilePathsMap = commandLineArgs.getSourceFilePathMap();

    // For each source path add a ReadOp to the graph
    String readOperatorAlias = OperatorSpi.getOperatorAlias(ReadOp.class);
    for (Entry<String, String> entry : sourceFilePathsMap.entrySet()) {
      String sourceId = entry.getKey();
      String sourceFilePath = entry.getValue();
      String sourceNodeId = sourceNodeIdMap.get(sourceId);
      if (graph.getNode(sourceNodeId) == null) {

        DomElement configuration = new DefaultDomElement("parameters");
        configuration.createChild("file").setValue(sourceFilePath);

        Node sourceNode = new Node(sourceNodeId, readOperatorAlias);
        sourceNode.setConfiguration(configuration);

        graph.addNode(sourceNode);
      }
    }

    final String operatorName = lastNode.getOperatorName();
    final OperatorSpi lastOpSpi = operatorSpiRegistry.getOperatorSpi(operatorName);
    if (lastOpSpi == null) {
      throw new GraphException(
          String.format("Unknown operator name '%s'. No SPI found.", operatorName));
    }

    if (!Output.class.isAssignableFrom(lastOpSpi.getOperatorClass())) {

      // If the graph's last node does not implement Output, then add a WriteOp
      String writeOperatorAlias = OperatorSpi.getOperatorAlias(WriteOp.class);

      DomElement configuration = new DefaultDomElement("parameters");
      configuration.createChild("file").setValue(commandLineArgs.getTargetFilePath());
      configuration.createChild("formatName").setValue(commandLineArgs.getTargetFormatName());
      configuration
          .createChild("clearCacheAfterRowWrite")
          .setValue(Boolean.toString(commandLineArgs.isClearCacheAfterRowWrite()));

      Node targetNode = new Node(WRITE_OP_ID_PREFIX + lastNode.getId(), writeOperatorAlias);
      targetNode.addSource(new NodeSource("source", lastNode.getId()));
      targetNode.setConfiguration(configuration);

      graph.addNode(targetNode);
    }
    executeGraph(graph);
    VelocityContext velocityContext = metadataResourceEngine.getVelocityContext();
    File graphFile = new File(commandLineArgs.getGraphFilePath());
    velocityContext.put("graph", graph);

    metadataResourceEngine.readResource("graphXml", graphFile.getPath());
  }