This commit is contained in:
Fabio Sinibaldi 2019-05-20 16:19:51 +00:00
parent b50eb7a437
commit 9790d6b3f8
8 changed files with 70 additions and 23 deletions

View File

@ -11,6 +11,18 @@
<description>Plugin for gCat-Feeder for DataMiner Algorithms publishing</description> <description>Plugin for gCat-Feeder for DataMiner Algorithms publishing</description>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>gcube-bom</artifactId>
<version>LATEST</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies> <dependencies>
<dependency> <dependency>
@ -25,7 +37,18 @@
<version>[1.6.0-SNAPSHOT,2.0.0-SNAPSHOT)</version> <version>[1.6.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
</dependency> </dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>provided</scope>
</dependency>
<!-- TEST --> <!-- TEST -->
<dependency> <dependency>
<groupId>org.gcube.data-publishing.gCat-Feeder</groupId> <groupId>org.gcube.data-publishing.gCat-Feeder</groupId>

View File

@ -16,6 +16,6 @@ public class Constants {
public static final String DEFAULT_MAINTAINER=ENVIRONMENT_PROPERTIES_BASE+"DEFAULT_MAINTAINER"; public static final String DEFAULT_MAINTAINER=ENVIRONMENT_PROPERTIES_BASE+"DEFAULT_MAINTAINER";
public static final String VISIBILITY=ENVIRONMENT_PROPERTIES_BASE+"VISIBILITY"; public static final String PRIVATE=ENVIRONMENT_PROPERTIES_BASE+"PRIVATE";
} }

View File

@ -1,5 +1,6 @@
package org.gcube.data.publishing.gCatFeeder.collectors.dm; package org.gcube.data.publishing.gCatFeeder.collectors.dm;
import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -33,7 +34,9 @@ public class DMAlgorithmsInfoCollector implements DataCollector<InternalAlgorith
public void setEnvironmentConfiguration(EnvironmentConfiguration envConfig) { public void setEnvironmentConfiguration(EnvironmentConfiguration envConfig) {
this.env=envConfig.getCurrentConfiguration(); if(envConfig!=null)
this.env=envConfig.getCurrentConfiguration();
else env=Collections.emptyMap();
} }
@ -88,6 +91,7 @@ public class DMAlgorithmsInfoCollector implements DataCollector<InternalAlgorith
desc.setId(opID); desc.setId(opID);
desc.setName(operatorName); desc.setName(operatorName);
desc.setAuthor(parseUser(getAuthor(opDescription))); desc.setAuthor(parseUser(getAuthor(opDescription)));
@ -113,7 +117,7 @@ public class DMAlgorithmsInfoCollector implements DataCollector<InternalAlgorith
if(wpsbaseUrl!=null) { if(wpsbaseUrl!=null) {
// desc.setWpsLink(wpsLink); // desc.setWpsLink(wpsLink);
} }
desc.setVisibility(env.get(Constants.VISIBILITY)); desc.setPrivateFlag(Boolean.parseBoolean(env.get(Constants.PRIVATE)));
toReturn.add(desc); toReturn.add(desc);
} }
@ -153,7 +157,7 @@ public class DMAlgorithmsInfoCollector implements DataCollector<InternalAlgorith
String splitter=null; String splitter=null;
if(userString.contains(" ")) if(userString.contains(" "))
splitter=" "; splitter=" ";
else if (userString.contains(".")) splitter="."; else if (userString.contains(".")) splitter="\\.";
String[] splitted=userString.split(splitter); String[] splitted=userString.split(splitter);
return new UserIdentity(splitted[0], splitted[1], null, null); return new UserIdentity(splitted[0], splitted[1], null, null);

View File

@ -1,5 +1,6 @@
package org.gcube.data.publishing.gCatFeeder.collectors.dm; package org.gcube.data.publishing.gCatFeeder.collectors.dm;
import java.io.InputStream;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
@ -64,10 +65,11 @@ public class DataMinerPlugin implements CollectorPlugin<InternalAlgorithmDescrip
@Override @Override
public void init() throws Exception { public void init() throws Exception {
log.debug("Initializing.."); log.debug("Initializing..");
Path p=Paths.get(this.getClass().getResource( "profile.xml").toURI());
log.debug("Path is : {} ",p.toUri()); InputStream is = getClass().getResourceAsStream("profile.xml");
GCatModel.setProfile( java.util.Scanner scanner = new java.util.Scanner(is).useDelimiter("\\A");
new String(Files.readAllBytes(p))); String json = scanner.hasNext() ? scanner.next() : "";
GCatModel.setProfile(json);
DataMinerCollectorProperties.init(); DataMinerCollectorProperties.init();

View File

@ -39,7 +39,7 @@ public class InternalAlgorithmDescriptor implements CustomData {
private String guiLink; private String guiLink;
private String wpsLink; private String wpsLink;
private String visibility; private Boolean privateFlag;
private List<String> tags=new ArrayList<>(); private List<String> tags=new ArrayList<>();

View File

@ -2,6 +2,8 @@ package org.gcube.data.publishing.gCatFeeder.collectors.dm.model.ckan;
import java.util.ArrayList; import java.util.ArrayList;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
@Getter @Getter
@ -9,6 +11,21 @@ import lombok.Setter;
public class CkanItem { public class CkanItem {
@Getter
@Setter
public static class Tag{
public Tag() {
// TODO Auto-generated constructor stub
}
public Tag(String value) {
name=value;
}
private String name;
}
public CkanItem() { public CkanItem() {
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
} }
@ -17,11 +34,12 @@ public class CkanItem {
private String title; private String title;
private String description; private String description;
private String version; private String version;
private String visibility; @JsonProperty("private")
private String license; private Boolean privateFlag;
private String license_id;
private String author; private String author;
private String maintainer; private String maintainer;
private ArrayList<String> tags=new ArrayList<String>(); private ArrayList<Tag> tags=new ArrayList<Tag>();
private ArrayList<CKanExtraField> extras=new ArrayList<>(); private ArrayList<CKanExtraField> extras=new ArrayList<>();
} }

View File

@ -37,18 +37,18 @@ public class GCatModel implements CatalogueFormatData {
// item.setAuthor(desc.getAuthor()); // item.setAuthor(desc.getAuthor());
item.setDescription(desc.getDescription()); item.setDescription(desc.getDescription());
item.setTitle(desc.getName()+" in "+ContextUtils.getCurrentScopeName()); item.setTitle(desc.getName()+" in "+ContextUtils.getCurrentScopeName());
item.setLicense("CC-BY-NC-SA-4.0"); item.setLicense_id("CC-BY-NC-SA-4.0");
// item.setMaintainer(desc.getMaintainer()); // item.setMaintainer(desc.getMaintainer());
item.setName(item.getTitle().toLowerCase().toLowerCase().replaceAll(" ", "_")); item.setName(item.getTitle().toLowerCase().toLowerCase().replaceAll(" ", "_"));
for(String tag:desc.getTags()) { for(String tag:desc.getTags()) {
item.getTags().add(fixTag(tag)); item.getTags().add(new CkanItem.Tag(fixTag(tag)));
} }
item.getTags().add(ContextUtils.getCurrentScopeName()); item.getTags().add(new CkanItem.Tag(ContextUtils.getCurrentScopeName()));
item.getTags().add("WPS"); item.getTags().add(new CkanItem.Tag("WPS"));
item.getTags().add("Analytics"); item.getTags().add(new CkanItem.Tag("Analytics"));
item.getExtras().add(new CKanExtraField("system", profileID)); item.getExtras().add(new CKanExtraField("system:type", profileID));
item.setVisibility(desc.getVisibility()); item.setPrivateFlag(desc.getPrivateFlag());
// TODO ADD PARAMETERS // TODO ADD PARAMETERS
for(Parameter param: desc.getParameters()) for(Parameter param: desc.getParameters())

View File

@ -1,21 +1,21 @@
<metadataformat type="DataMiner Process"> <metadataformat type="DataMiner Process">
<metadatafield> <metadatafield>
<fieldName>Input Parameter</fieldName> <fieldName>Input Parameter</fieldName>
<dataType>String</dataType>
<mandatory>false</mandatory> <mandatory>false</mandatory>
<dataType>String</dataType>
<note>Input parameter expected for the execution of the process</note> <note>Input parameter expected for the execution of the process</note>
</metadatafield> </metadatafield>
<metadatafield> <metadatafield>
<fieldName>Output Parameter</fieldName> <fieldName>Output Parameter</fieldName>
<dataType>String</dataType>
<mandatory>false</mandatory> <mandatory>false</mandatory>
<dataType>String</dataType>
<note>Output parameter expected from the execution of the process <note>Output parameter expected from the execution of the process
</note> </note>
</metadatafield> </metadatafield>
<metadatafield> <metadatafield>
<fieldName>Process Author</fieldName> <fieldName>Process Author</fieldName>
<dataType>String</dataType>
<mandatory>false</mandatory> <mandatory>false</mandatory>
<dataType>String</dataType>
<maxOccurs>*</maxOccurs> <maxOccurs>*</maxOccurs>
<defaultValue /> <defaultValue />
<note>The name of the author, with email and ORCID. The format should <note>The name of the author, with email and ORCID. The format should