/** * this function update the number of extra input file accorrdingly with the current number of * files it deletes or adds extra input files */ private void _updateUploadFileNumber(int numFiles) throws IllegalActionException { int currentNumberOfFile = 0; try { currentNumberOfFile = _getUploadFileNumber(); } catch (IllegalActionException e) { throw new IllegalActionException(this, "Unable to load opal paraters:" + e.getMessage()); } int diff = numFiles - currentNumberOfFile; if (diff > 0) { // we have to add diff number of input files for (int i = 0; i < diff; i++) { try { (new FilePortParameter(this, "inputFile" + (currentNumberOfFile + 1 + i) + "Dynamic")) .setContainer(this); } catch (NameDuplicationException e) { throw new IllegalActionException(this, "There is a name duplication: " + e.getMessage()); } // catch } // for } else if (diff < 0) { // we have to delete number of files for (int i = 0; i < Math.abs(diff); i++) { String fileName = "inputFile" + (currentNumberOfFile - i) + "Dynamic"; try { FilePortParameter fileToBeDeleted = (FilePortParameter) this.getAttribute(fileName, FilePortParameter.class); fileToBeDeleted.getPort().setContainer(null); fileToBeDeleted.setContainer(null); } catch (NameDuplicationException e) { throw new IllegalActionException( this, "Unable to delete the input file " + fileName + ": " + e.getMessage()); } // catch } // for } // if // diff == 0 don't do anything } // _updateUploadFileNumber
/** * this function instantiate all the parameter necessary to display an advanced submission form * for the current selected opal service */ private void _createSubmission(AppMetadata app) throws IllegalActionException { _emptyParamtersArray(); log.info("Creating complex submission form. For service URL: " + app.getURL()); try { Group[] group = app.getGroups(); ArrayList tempParam = new ArrayList(); if (group != null) { for (int i = 0; i < group.length; i++) { // first the parameters ArgParam[] argParams = group[i].getArgParams(); if (argParams != null) { for (int paramCount = 0; paramCount < argParams.length; paramCount++) { if (argParams[paramCount].getType().equals("FILE") && argParams[paramCount].getIoType().equals("INPUT")) { // This is an input file box FilePortParameter param = new FilePortParameter(this, argParams[paramCount].getId()); if (argParams[paramCount].getSelectedValue() != null) // setting the default value param.setExpression(argParams[paramCount].getSelectedValue()); tempParam.add(param); } else if (argParams[paramCount].getValues() != null) { String[] choices = argParams[paramCount].getValues(); // this is a multiple choices StringParameter param = new StringParameter(this, argParams[paramCount].getId()); for (int z = 0; z < choices.length; z++) param.addChoice(choices[z]); if (argParams[paramCount].getSelectedValue() != null) // setting the default value param.setExpression(argParams[paramCount].getSelectedValue()); tempParam.add(param); } else { // this is a string StringParameter param = new StringParameter(this, argParams[paramCount].getId()); if (argParams[paramCount].getSelectedValue() != null) // setting the default value param.setExpression(argParams[paramCount].getSelectedValue()); tempParam.add(param); } // else } // for argParam } // argParams // and then the flags ArgFlag[] argFlags = group[i].getArgFlags(); if (argFlags != null) { for (int paramCount = 0; paramCount < argFlags.length; paramCount++) { Parameter check = null; if (argFlags[paramCount].isSelected()) check = new Parameter(this, argFlags[paramCount].getId(), BooleanToken.TRUE); else check = new Parameter(this, argFlags[paramCount].getId(), BooleanToken.FALSE); check.setTypeEquals(BaseType.BOOLEAN); tempParam.add(check); } } // argFlags } } // group // set the numberFiles to 0 StringParameter param = (StringParameter) this.getAttribute("numberFiles"); if (param != null) param.setToken(new StringToken("0")); // not needed anymore delete the tempParam // _interfaceParameters = (Parameter []) tempParam.toArray(new // Parameter[tempParam.size()]); } catch (NameDuplicationException e) { log.error("The parameter could not be instantiated. Error message: " + e.getMessage()); throw new IllegalActionException( this, "The complex submission form could not be initialized: " + e.getMessage()); } return; }