ref 10523: Fixed Set Main behavior in case of R
https://support.d4science.org/issues/10523 Fixed Set Main behavior in case of R git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/statistical-algorithms-importer@160310 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
2a2eabfce7
commit
874f744833
|
@ -317,7 +317,10 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
String link = filesStorage.getPublicLink(serviceCredentials.getUserName(), itemDescription.getId());
|
||||
itemDescription.setPublicLink(link);
|
||||
project.setMainCode(new MainCode(itemDescription));
|
||||
project.setInputData(null);
|
||||
InputData inputData=project.getInputData();
|
||||
if(inputData!=null){
|
||||
inputData.setListInputOutputVariables(null);
|
||||
}
|
||||
project.setProjectTarget(null);
|
||||
WPS4RParser wps4Parser = new WPS4RParser(project, serviceCredentials);
|
||||
project = wps4Parser.parse();
|
||||
|
@ -646,6 +649,28 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String getPublicLink(ItemDescription itemDescription) throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
|
||||
logger.debug("GetPublicLink(): " + itemDescription);
|
||||
FilesStorage filesStorage = new FilesStorage();
|
||||
String link = filesStorage.getPublicLink(serviceCredentials.getUserName(), itemDescription.getId());
|
||||
|
||||
return link;
|
||||
} catch (StatAlgoImporterServiceException e) {
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
logger.error("getPublicLink(): " + e.getLocalizedMessage(), e);
|
||||
e.printStackTrace();
|
||||
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Project createSoftware(InputData inputData) throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
|
@ -678,26 +703,6 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPublicLink(ItemDescription itemDescription) throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
|
||||
logger.debug("GetPublicLink(): " + itemDescription);
|
||||
FilesStorage filesStorage = new FilesStorage();
|
||||
String link = filesStorage.getPublicLink(serviceCredentials.getUserName(), itemDescription.getId());
|
||||
|
||||
return link;
|
||||
} catch (StatAlgoImporterServiceException e) {
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
logger.error("getPublicLink(): " + e.getLocalizedMessage(), e);
|
||||
e.printStackTrace();
|
||||
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String publishSoftware() throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
|
|
|
@ -36,8 +36,7 @@ import org.slf4j.LoggerFactory;
|
|||
*/
|
||||
public class WPS4RParser {
|
||||
|
||||
public static final Logger logger = LoggerFactory
|
||||
.getLogger(WPS4RParser.class);
|
||||
public static final Logger logger = LoggerFactory.getLogger(WPS4RParser.class);
|
||||
|
||||
private Project project;
|
||||
private ServiceCredentials serviceCredentials;
|
||||
|
@ -51,8 +50,7 @@ public class WPS4RParser {
|
|||
logger.debug("MainCode: " + project.getMainCode());
|
||||
ItemDescription mainCode = project.getMainCode().getItemDescription();
|
||||
FilesStorage fileStorage = new FilesStorage();
|
||||
InputStream is = fileStorage.retrieveItemOnWorkspace(
|
||||
serviceCredentials.getUserName(), mainCode.getId());
|
||||
InputStream is = fileStorage.retrieveItemOnWorkspace(serviceCredentials.getUserName(), mainCode.getId());
|
||||
logger.debug("MainCode InputStream: " + is);
|
||||
|
||||
Path tempFile = null;
|
||||
|
@ -77,8 +75,7 @@ public class WPS4RParser {
|
|||
try {
|
||||
RAnnotationParser parser = new RAnnotationParser(config);
|
||||
logger.debug("RAnnotations Parser:" + parser);
|
||||
annotations = parser.parseAnnotationsfromScript(Files
|
||||
.newInputStream(tempFile, StandardOpenOption.READ));
|
||||
annotations = parser.parseAnnotationsfromScript(Files.newInputStream(tempFile, StandardOpenOption.READ));
|
||||
} catch (RAnnotationException e) {
|
||||
e.printStackTrace();
|
||||
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
|
||||
|
@ -97,54 +94,53 @@ public class WPS4RParser {
|
|||
|
||||
WPSAlgorithmInfo wpsAlgorithmInfo = mapAnnotations(annotations);
|
||||
logger.debug("wpsAlgorithmInfo: " + wpsAlgorithmInfo);
|
||||
if (wpsAlgorithmInfo == null
|
||||
|| wpsAlgorithmInfo.getAlgorithmName() == null)
|
||||
if (wpsAlgorithmInfo == null || wpsAlgorithmInfo.getAlgorithmName() == null)
|
||||
return project;
|
||||
else
|
||||
return mapToProject(wpsAlgorithmInfo);
|
||||
|
||||
}
|
||||
|
||||
private Project mapToProject(WPSAlgorithmInfo wpsAlgorithmInfo)
|
||||
throws StatAlgoImporterServiceException {
|
||||
private Project mapToProject(WPSAlgorithmInfo wpsAlgorithmInfo) throws StatAlgoImporterServiceException {
|
||||
if (project == null) {
|
||||
throw new StatAlgoImporterServiceException("Open project before!");
|
||||
}
|
||||
|
||||
if (project.getInputData() == null) {
|
||||
ProjectInfo projectInfo = new ProjectInfo(
|
||||
wpsAlgorithmInfo.getAlgorithmName(),
|
||||
ProjectInfo projectInfo = new ProjectInfo(wpsAlgorithmInfo.getAlgorithmName(),
|
||||
wpsAlgorithmInfo.getDescription(), null);
|
||||
InputData inputData = new InputData(projectInfo, null, null,
|
||||
wpsAlgorithmInfo.getInputOutputVariables());
|
||||
InputData inputData = new InputData(projectInfo, null, null, wpsAlgorithmInfo.getInputOutputVariables());
|
||||
project.setInputData(inputData);
|
||||
} else {
|
||||
if (project.getInputData().getProjectInfo() == null) {
|
||||
InputData inputData = project.getInputData();
|
||||
ProjectInfo projectInfo = new ProjectInfo(
|
||||
wpsAlgorithmInfo.getAlgorithmName(),
|
||||
ProjectInfo projectInfo = new ProjectInfo(wpsAlgorithmInfo.getAlgorithmName(),
|
||||
wpsAlgorithmInfo.getDescription(), null);
|
||||
inputData.setProjectInfo(projectInfo);
|
||||
inputData.setListInputOutputVariables(wpsAlgorithmInfo
|
||||
.getInputOutputVariables());
|
||||
inputData.setListInputOutputVariables(wpsAlgorithmInfo.getInputOutputVariables());
|
||||
} else {
|
||||
InputData inputData = project.getInputData();
|
||||
ProjectInfo projectInfo = new ProjectInfo(
|
||||
wpsAlgorithmInfo.getAlgorithmName(),
|
||||
wpsAlgorithmInfo.getDescription(), project
|
||||
.getInputData().getProjectInfo()
|
||||
.getAlgorithmCategory());
|
||||
ProjectInfo projectInfo = project.getInputData().getProjectInfo();
|
||||
|
||||
if (project.getInputData().getProjectInfo().getAlgorithmName() == null
|
||||
|| project.getInputData().getProjectInfo().getAlgorithmName().isEmpty()) {
|
||||
projectInfo.setAlgorithmName(wpsAlgorithmInfo.getAlgorithmName());
|
||||
}
|
||||
|
||||
if (project.getInputData().getProjectInfo().getAlgorithmDescription() == null
|
||||
|| project.getInputData().getProjectInfo().getAlgorithmDescription().isEmpty()) {
|
||||
projectInfo.setAlgorithmDescription(wpsAlgorithmInfo.getDescription());
|
||||
}
|
||||
|
||||
inputData.setProjectInfo(projectInfo);
|
||||
inputData.setListInputOutputVariables(wpsAlgorithmInfo
|
||||
.getInputOutputVariables());
|
||||
inputData.setListInputOutputVariables(wpsAlgorithmInfo.getInputOutputVariables());
|
||||
}
|
||||
}
|
||||
return project;
|
||||
|
||||
}
|
||||
|
||||
private WPSAlgorithmInfo mapAnnotations(List<RAnnotation> annotations)
|
||||
throws StatAlgoImporterServiceException {
|
||||
private WPSAlgorithmInfo mapAnnotations(List<RAnnotation> annotations) throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
|
||||
WPSAlgorithmInfo wpsAlgorithmInfo = new WPSAlgorithmInfo();
|
||||
|
@ -153,28 +149,20 @@ public class WPS4RParser {
|
|||
for (RAnnotation rAnnotation : annotations) {
|
||||
logger.debug("RAnnotation: " + rAnnotation);
|
||||
if (rAnnotation.getType().equals(RAnnotationType.DESCRIPTION)) {
|
||||
wpsAlgorithmInfo.setVersion(rAnnotation
|
||||
.getStringValue(RAttribute.VERSION));
|
||||
wpsAlgorithmInfo.setDescription(rAnnotation
|
||||
.getStringValue(RAttribute.ABSTRACT));
|
||||
String algorithmName = rAnnotation
|
||||
.getStringValue(RAttribute.TITLE);
|
||||
algorithmName = algorithmName.replaceAll("[^A-Za-z0-9]",
|
||||
"_");
|
||||
wpsAlgorithmInfo.setVersion(rAnnotation.getStringValue(RAttribute.VERSION));
|
||||
wpsAlgorithmInfo.setDescription(rAnnotation.getStringValue(RAttribute.ABSTRACT));
|
||||
String algorithmName = rAnnotation.getStringValue(RAttribute.TITLE);
|
||||
algorithmName = algorithmName.replaceAll("[^A-Za-z0-9]", "_");
|
||||
wpsAlgorithmInfo.setAlgorithmName(algorithmName);
|
||||
wpsAlgorithmInfo.setVersion(rAnnotation
|
||||
.getStringValue(RAttribute.VERSION));
|
||||
wpsAlgorithmInfo.setVersion(rAnnotation.getStringValue(RAttribute.VERSION));
|
||||
} else if (rAnnotation.getType().equals(RAnnotationType.OUTPUT)
|
||||
|| rAnnotation.getType().equals(RAnnotationType.INPUT)) {
|
||||
// output, text, Random number list,
|
||||
|
||||
String type = rAnnotation.getStringValue(RAttribute.TYPE);
|
||||
String name = rAnnotation
|
||||
.getStringValue(RAttribute.IDENTIFIER);
|
||||
String description = rAnnotation
|
||||
.getStringValue(RAttribute.TITLE);
|
||||
String defaultValue = rAnnotation
|
||||
.getStringValue(RAttribute.DEFAULT_VALUE);
|
||||
String name = rAnnotation.getStringValue(RAttribute.IDENTIFIER);
|
||||
String description = rAnnotation.getStringValue(RAttribute.TITLE);
|
||||
String defaultValue = rAnnotation.getStringValue(RAttribute.DEFAULT_VALUE);
|
||||
if (type == null)
|
||||
type = "string";
|
||||
if (name == null)
|
||||
|
@ -190,13 +178,11 @@ public class WPS4RParser {
|
|||
ioType = IOType.OUTPUT;
|
||||
|
||||
DataType dataType = WPStype2DataType(type);
|
||||
if (defaultValue != null && defaultValue.contains("|")
|
||||
&& dataType == DataType.STRING)
|
||||
if (defaultValue != null && defaultValue.contains("|") && dataType == DataType.STRING)
|
||||
dataType = DataType.ENUMERATED;
|
||||
|
||||
InputOutputVariables ioVariable = new InputOutputVariables(
|
||||
index, name, description, defaultValue, dataType,
|
||||
ioType, "");
|
||||
InputOutputVariables ioVariable = new InputOutputVariables(index, name, description, defaultValue,
|
||||
dataType, ioType, "");
|
||||
inputOutputVariables.add(ioVariable);
|
||||
index++;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue