/** * This method instantiates the parameters needed for the submission of a Opal job without * metadata */ private void _createSimpleSubmission(AppMetadata app) throws IllegalActionException { _emptyParamtersArray(); // TODO delete this _interfaceParameters is useless log.info("Creating simple submission form. For service URL: " + app.getURL()); try { (new StringParameter(this, "commandLine")).setContainer(this); (new StringParameter(this, "cpuNumber")).setContainer(this); // let's try to get the number of files int numFiles; try { numFiles = Integer.parseInt(numberFiles.stringValue()); } catch (NumberFormatException e) { throw new IllegalActionException( this, "The numberFiles parameter is not a valid integer, please correct the value"); } _updateUploadFileNumber(numFiles); } catch (NameDuplicationException e) { log.error("The parameter could not be instantiated. Error message: " + e.getMessage(), e); } }
/** * this function adds all the parameters necessary to have the documentation of the OpalClient * abviously this documentation is fetch from the remote server */ private void _addDocumentation(AppMetadata app) throws IllegalActionException { // let's get the variable we need Attribute documentation = this.getAttribute("KeplerDocumentation"); if (documentation == null) throw new IllegalActionException( this, "Unable to set the custom documentation (KeplerDocumentation not present)."); Attribute userDoc = documentation.getAttribute("userLevelDocumentation"); if (userDoc == null) throw new IllegalActionException( this, "Unable to set the custom documentation (userLevelDocumentation not present)."); // -- we have to delete all the documentation that is already there // before updating it List tempList = documentation.attributeList(); Attribute[] paramArray = (Attribute[]) tempList.toArray(new Attribute[tempList.size()]); for (int i = 0; i < paramArray.length; i++) { try { if (paramArray[i].getName().startsWith("prop:") || paramArray[i].getName().startsWith("port:output") || paramArray[i].getName().startsWith("port:baseUrl")) // let's remove the parameters paramArray[i].setContainer(null); } catch (NameDuplicationException e) { log.error( "The parameter could not be deleted from the documentation. Error message: " + e.getMessage()); throw new IllegalActionException( this, "Error resetting the ducumentation, there is a duplicated name: " + e.getMessage()); } } // After deleting we can finally set the documentation String stringDoc = _docHead; // let's set the general documentaion if (app.getUsage() != null) stringDoc += "<p>" + app.getUsage() + "</p>"; if (app.getInfo() != null) { String[] infos = app.getInfo(); for (int i = 0; i < infos.length; i++) stringDoc += "<pre>" + forXML(infos[i]) + "</pre>"; } // if log.debug("the stringDoc is: " + stringDoc); ((ConfigurableAttribute) userDoc).setExpression(stringDoc); // -- let's set the documentation for the various properties -- // some properties are always there... hence also the documentation // should be always there try { ((ConfigurableAttribute) userDoc).value(); ConfigurableAttribute parameterDoc = new ConfigurableAttribute(documentation, "port:output"); parameterDoc.setExpression( "It returns a list of Strings, containing the URL of the output files"); parameterDoc = new ConfigurableAttribute(documentation, "port:baseUrl"); parameterDoc.setExpression( "The base URL containing the working directory of the running jobs"); parameterDoc = new ConfigurableAttribute(documentation, "prop:serviceURL"); parameterDoc.setExpression("The URL of the Opal service that you want to execute"); parameterDoc = new ConfigurableAttribute(documentation, "prop:numberOfExtraInputFiles"); parameterDoc.setExpression( "The number of extra input files that are needed to execture the application"); // parameterDoc = new ConfigurableAttribute(documentation, // "prop:methods"); // parameterDoc.setExpression("Not implemented yet."); } catch (NameDuplicationException e) { log.error("The parameter could not be instantiated. Error message: " + e.getMessage()); throw new IllegalActionException( this, "Error building the ducumentation, there is a duplicated name: " + e.getMessage()); } catch (IOException e) { log.error("There is an error while setting the general documentation: " + e.getMessage()); } // we have to list the documentation for every parameters if (app.isArgMetadataEnable()) { Group[] group = app.getGroups(); try { 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++) { ConfigurableAttribute parameterDoc = new ConfigurableAttribute( documentation, "prop:" + argParams[paramCount].getId()); parameterDoc.setExpression(forXML(argParams[paramCount].getTextDesc())); } // for argParam } // argParams // and then the flags ArgFlag[] argFlags = group[i].getArgFlags(); if (argFlags != null) { for (int paramCount = 0; paramCount < argFlags.length; paramCount++) { ConfigurableAttribute parameterDoc = new ConfigurableAttribute( documentation, "prop:" + argFlags[paramCount].getId()); parameterDoc.setExpression(forXML(argFlags[paramCount].getTextDesc())); log.info( "The parameter " + argFlags[paramCount].getId() + " has the following doc: " + parameterDoc.value()); parameterDoc.validate(); } } // argFlags } } // group } catch (NameDuplicationException e) { log.error("The parameter could not be instantiated. Error message: " + e.getMessage()); throw new IllegalActionException( this, "Error building the ducumentation, there is a duplicated name: " + e.getMessage()); } catch (IOException e) { log.error( "There is an error while setting the documentation of an element with messge: " + e.getMessage()); } } // if we have metadata else { // if we don't have metadata we document the standard parameters try { ConfigurableAttribute parameterDoc = new ConfigurableAttribute(documentation, "prop:commandLine"); parameterDoc.setExpression( "Insert the command line you want to execute (without the application name)"); parameterDoc = new ConfigurableAttribute(documentation, "prop:cpuNumber"); parameterDoc.setExpression("If it is a parallel application insert the CPU number"); parameterDoc = new ConfigurableAttribute(documentation, "prop:inputFile"); parameterDoc.setExpression("Select an input file"); } catch (NameDuplicationException e) { log.error("The parameter could not be instantiated. Error message: " + e.getMessage()); throw new IllegalActionException( this, "Error building the ducumentation, there is a duplicated name: " + e.getMessage()); } } } // _addDocumentation
/** * 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; }