// Retrieves the output product name from request private String getOutputProductNameSafe() throws ProcessorException { Request request = getRequest(); ProductRef prod = request.getOutputProductAt(0); if (prod == null) { throw new ProcessorException(ProcessorConstants.LOG_MSG_NO_OUTPUT_IN_REQUEST); } File prodFile = new File(prod.getFilePath()); return FileUtils.getFilenameWithoutExtension(prodFile); }
// Creates the appropriate <code>Product</code> for the current request and assembles a list of // <code>RsBands</code> // to be processed. This method does NOT load the tie point ADS because these are product // specific. private void loadInputProduct() throws IOException, ProcessorException { Request request = getRequest(); Band band; Parameter bandParam; String[] bandNames; // clear vector of bands // --------------------- _inputBandList.clear(); // only the first product - there might be more but these will be ignored // ---------------------------------------------------------------------- _inputProduct = loadInputProduct(0); // check what product type the input is and load the appropriate tie point ADS // --------------------------------------------------------------------------- _sensorType = SmacUtils.getSensorType(_inputProduct.getProductType()); if (ObjectUtils.equalObjects(_sensorType, SensorCoefficientManager.MERIS_NAME)) { loadMerisBitmaskExpression(); loadMERIS_ADS(_inputProduct); } else if (ObjectUtils.equalObjects(_sensorType, SensorCoefficientManager.AATSR_NAME)) { loadAatsrBitmaskExpression(); loadAATSR_ADS(_inputProduct); _useMerisADS = false; // then we must set this to false anyway } else { throw new ProcessorException(SmacConstants.LOG_MSG_UNSUPPORTED_SENSOR); } // set up the bands we need for this request // ----------------------------------------- bandParam = request.getParameter(SmacConstants.BANDS_PARAM_NAME); checkParamNotNull(bandParam, "bands"); bandNames = (String[]) bandParam.getValue(); if ((bandNames == null) || (bandNames.length < 1)) { throw new ProcessorException(SmacConstants.LOG_MSG_NO_INPUT_BANDS); } for (String bandName : bandNames) { band = _inputProduct.getBand(bandName); if (band == null) { _logger.warning( "The requested band '" + bandName + "' is not contained in the input product!"); } else { if (band.getSpectralBandIndex() != -1) { _inputBandList.add(band); } else { _logger.warning( "The requested band '" + bandName + "' is not a spectral band! It is excluded from processing"); } } } }
/** * Fills the given {@link Request request} with parameters. * * @param request the request to fill * @throws ProcessorException if an error occurred */ @Override public void initRequestFromUI(final Request request) throws ProcessorException { request.addInputProduct(createInputProductRef()); final Parameter outputProductParam = getParamGroup().getParameter(OUTPUT_PRODUCT_PARAM_NAME); if (StringUtils.isNullOrEmpty(outputProductParam.getValueAsText())) { throw new ProcessorException("No output product specified."); /*I18N*/ } request.addOutputProduct(createOutputProductRef()); request.addParameter(createOutputFormatParamForRequest()); request.addParameter(getParamGroup().getParameter(LOG_PREFIX_PARAM_NAME)); request.addParameter(getParamGroup().getParameter(LOG_TO_OUTPUT_PARAM_NAME)); }
/** Tries to load the <code>ProductRef</code> for the output product from the request. */ protected void loadOutputProductFromRequest() throws ProcessorException { Request request; request = getRequest(); if (request.getNumOutputProducts() > 0) { ProductRef ref = request.getOutputProductAt(0); if (ref == null) { handleError(ProcessorConstants.LOG_MSG_NO_OUTPUT_IN_REQUEST); } outputProductRef = ref; } else { handleError(ProcessorConstants.LOG_MSG_NO_OUTPUT_IN_REQUEST); } }
/** Loads the bitmask expression for an AATSR product from the request */ private void loadAatsrBitmaskExpression() { Request request = getRequest(); Parameter paramNadir = request.getParameter(SmacConstants.BITMASK_NADIR_PARAM_NAME); if (paramNadir != null) { _bitMaskExpression = paramNadir.getValueAsText(); } else { _bitMaskExpression = ""; } Parameter paramForward = request.getParameter(SmacConstants.BITMASK_FORWARD_PARAM_NAME); if (paramForward != null) { _bitMaskExpressionForward = paramForward.getValueAsText(); } else { _bitMaskExpressionForward = ""; } }
private void updateLogParameter(final Request request) { Parameter param; Parameter toUpdate; param = request.getParameter(LOG_PREFIX_PARAM_NAME); final ParamGroup paramGroup = getParamGroup(); if (param != null) { toUpdate = paramGroup.getParameter(LOG_PREFIX_PARAM_NAME); toUpdate.setValue(param.getValue(), null); } param = request.getParameter(LOG_TO_OUTPUT_PARAM_NAME); if (param != null) { toUpdate = paramGroup.getParameter(LOG_TO_OUTPUT_PARAM_NAME); toUpdate.setValue(param.getValue(), null); } }
private void updateParamOutputFormat(final Request request) { final Parameter parameter = request.getParameter(OUTPUT_FORMAT_PARAM_NAME); if (parameter != null) { final String format = parameter.getValueAsText(); final ProductIOPlugInManager instance = ProductIOPlugInManager.getInstance(); final String[] allowedformats = instance.getAllProductWriterFormatStrings(); if (ArrayUtils.isMemberOf(format, allowedformats)) { getParamGroup().getParameter(OUTPUT_FORMAT_PARAM_NAME).setValue(format, null); } } }
private void updateParamInputFile(final Request request) { final File file = new File(request.getInputProductAt(0).getFilePath()); getParamGroup().getParameter(INPUT_PRODUCT_PARAM_NAME).setValue(file, null); }