git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-publishing/gCat-Feeder-Suite@178798 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
4e512ef3d1
commit
6100cf8afb
|
@ -6,11 +6,11 @@ import java.util.Set;
|
|||
|
||||
import org.gcube.data.analysis.dataminermanagercl.server.DataMinerService;
|
||||
import org.gcube.data.analysis.dataminermanagercl.server.dmservice.SClient;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.Parameter;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.process.Operator;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.process.OperatorCategory;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.process.OperatorsClassification;
|
||||
import org.gcube.data.publishing.gCatFeeder.collectors.dm.model.InternalAlgorithmDescriptor;
|
||||
import org.gcube.data.publishing.gCatFeeder.collectors.dm.model.InternalAlgorithmDescriptor.Parameter;
|
||||
import org.gcube.data.publishing.gCatfeeder.collectors.DataCollector;
|
||||
import org.gcube.data.publishing.gCatfeeder.collectors.model.faults.CollectorFault;
|
||||
|
||||
|
@ -70,18 +70,22 @@ public class DMAlgorithmsInfoCollector implements DataCollector<InternalAlgorith
|
|||
desc.setId(opID);
|
||||
desc.setName(operatorName);
|
||||
|
||||
|
||||
|
||||
desc.setAuthor(DataMinerCollectorProperties.getProperty(DataMinerCollectorProperties.DEFAULT_AUTHOR));
|
||||
desc.setMaintainer(DataMinerCollectorProperties.getProperty(DataMinerCollectorProperties.DEFAULT_AUTHOR));
|
||||
// Parameters info
|
||||
for(Parameter param:op.getOperatorParameters()) {
|
||||
for(org.gcube.data.analysis.dataminermanagercl.shared.parameters.Parameter param:op.getOperatorParameters()) {
|
||||
String paramDescription=param.getDescription();
|
||||
String paramName=param.getName();
|
||||
String paramType=param.getTypology().toString();
|
||||
String paramValue=param.getValue();
|
||||
|
||||
desc.getParameters().add(
|
||||
new Parameter(paramName, paramType, paramDescription, paramValue));
|
||||
|
||||
}
|
||||
|
||||
|
||||
// op.get
|
||||
desc.getTags().add(categoryName);
|
||||
|
||||
toReturn.add(desc);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package org.gcube.data.publishing.gCatFeeder.collectors.dm;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
public class DataMinerCollectorProperties {
|
||||
|
||||
public static final String DEFAULT_AUTHOR="default_author";
|
||||
|
||||
|
||||
private static Properties props;
|
||||
|
||||
public static void init() throws IOException {
|
||||
props=new Properties();
|
||||
props.load(DataMinerCollectorProperties.class.getResourceAsStream("config.properties"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static String getProperty(String key) {
|
||||
return props.getProperty(key);
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@ import java.nio.file.Files;
|
|||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Collections;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import org.gcube.data.publishing.gCatFeeder.collectors.dm.model.InternalAlgorithmDescriptor;
|
||||
|
@ -22,6 +23,10 @@ import lombok.extern.slf4j.Slf4j;
|
|||
@Slf4j
|
||||
public class DataMinerPlugin implements CollectorPlugin<InternalAlgorithmDescriptor> {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public PluginDescriptor getDescriptor() {
|
||||
return new PluginDescriptor("DATA_MINER_ALGORITHMS");
|
||||
|
@ -61,6 +66,9 @@ public class DataMinerPlugin implements CollectorPlugin<InternalAlgorithmDescrip
|
|||
log.debug("Path is : {} ",p.toUri());
|
||||
GCatModel.setProfile(
|
||||
new String(Files.readAllBytes(p)));
|
||||
|
||||
DataMinerCollectorProperties.init();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -58,6 +58,9 @@ public class InternalAlgorithmDescriptor implements CustomData {
|
|||
private String briefDescription;
|
||||
private String id;
|
||||
|
||||
private String author;
|
||||
private String maintainer;
|
||||
|
||||
//category info
|
||||
|
||||
private String categoryBriefDescription;
|
||||
|
|
|
@ -30,16 +30,21 @@ public class GCatModel implements CatalogueFormatData {
|
|||
|
||||
public GCatModel(InternalAlgorithmDescriptor desc) {
|
||||
item=new CkanItem();
|
||||
// item.setAuthor(desc.getAuthor());
|
||||
item.setAuthor(desc.getAuthor());
|
||||
item.setDescription(desc.getDescription());
|
||||
item.setTitle(desc.getName()+" in "+ContextUtils.getCurrentScopeName());
|
||||
item.setLicense("CC-BY-NC-SA-4.0");
|
||||
// item.setMaintainer(desc.getAuthor());
|
||||
item.setMaintainer(desc.getMaintainer());
|
||||
item.setName(item.getTitle().toLowerCase().toLowerCase().replaceAll(" ", "_"));
|
||||
for(String tag:desc.getTags()) {
|
||||
item.getTags().add(fixTag(tag));
|
||||
}
|
||||
item.getExtras().add(new CKanExtraField("system", "Algorithm"));
|
||||
|
||||
// TODO ADD PARAMETERS
|
||||
|
||||
// TODO ADD RESOURCES
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
default_author=gianpaolo.coro
|
|
@ -0,0 +1 @@
|
|||
org.gcube.data.publishing.gCataFeeder.catalogues.gCat.GCatPlugin
|
|
@ -12,14 +12,14 @@ import org.gcube.data.publishing.gCatFeeder.catalogues.model.faults.WrongObjectF
|
|||
import org.gcube.data.publishing.gCatFeeder.model.CatalogueFormatData;
|
||||
import org.gcube.data.publishing.gCatFeeder.model.CatalogueInstanceDescriptor;
|
||||
import org.gcube.data.publishing.gCatFeeder.model.InternalConversionException;
|
||||
import org.gcube.data.publishing.gCatFeeder.tests.TokenSetter;
|
||||
import org.gcube.data.publishing.gCatFeeder.tests.BaseCataloguePluginTest;
|
||||
import org.gcube.data.publishing.gCataFeeder.catalogues.gCat.GCatPlugin;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Assume;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
public class Interactions {
|
||||
public class Interactions extends BaseCataloguePluginTest{
|
||||
|
||||
private static class CustomTargetFormat implements CatalogueFormatData{
|
||||
|
||||
|
@ -41,10 +41,7 @@ public class Interactions {
|
|||
}
|
||||
|
||||
|
||||
@Before
|
||||
public void setToken() {
|
||||
TokenSetter.set("/gcube/preprod/preVRE");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -64,6 +61,7 @@ public class Interactions {
|
|||
|
||||
@Test
|
||||
public void duplicates() {
|
||||
Assume.assumeTrue(isTestInfrastructureEnabled());
|
||||
try {
|
||||
publish(getController(),"full.json");
|
||||
publish(getController(),"full.json");
|
||||
|
@ -75,23 +73,27 @@ public class Interactions {
|
|||
|
||||
@Test(expected=WrongObjectFormatException.class)
|
||||
public void empties() throws CatalogueInteractionException, WrongObjectFormatException, PublicationException, ControllerInstantiationFault, InternalConversionException {
|
||||
Assume.assumeTrue(isTestInfrastructureEnabled());
|
||||
publish(getController(),"empties.json");
|
||||
}
|
||||
|
||||
|
||||
@Test(expected=PublicationException.class)
|
||||
public void missingProfile() throws CatalogueInteractionException, WrongObjectFormatException, PublicationException, ControllerInstantiationFault, InternalConversionException {
|
||||
Assume.assumeTrue(isTestInfrastructureEnabled());
|
||||
publish(getController(),"missingProfile.json");
|
||||
}
|
||||
|
||||
|
||||
@Test(expected=WrongObjectFormatException.class)
|
||||
public void noitem() throws CatalogueInteractionException, WrongObjectFormatException, PublicationException, ControllerInstantiationFault, InternalConversionException {
|
||||
Assume.assumeTrue(isTestInfrastructureEnabled());
|
||||
publish(getController(),"noItem.json");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void item() {
|
||||
Assume.assumeTrue(isTestInfrastructureEnabled());
|
||||
try {
|
||||
publish(getController(),"onlyItem.json");
|
||||
} catch (WrongObjectFormatException | PublicationException | ControllerInstantiationFault | InternalConversionException e) {
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
org.gcube.data.publishing.gCataFeeder.catalogues.gCat.GCatPlugin
|
Binary file not shown.
|
@ -10,7 +10,7 @@ import org.junit.Test;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class BaseCataloguePluginTest {
|
||||
public class BaseCataloguePluginTest extends InfrastructureTests{
|
||||
|
||||
private static final Logger log= LoggerFactory.getLogger(BaseCataloguePluginTest.class);
|
||||
|
||||
|
@ -19,7 +19,7 @@ public class BaseCataloguePluginTest {
|
|||
|
||||
|
||||
@BeforeClass
|
||||
public void checkPluginRegistration() {
|
||||
public static void checkPluginRegistration() {
|
||||
int pluginsCounter=0;
|
||||
for(CataloguePlugin pl:cataloguePluginsLoader) {
|
||||
pluginsCounter++;
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
package org.gcube.data.publishing.gCatFeeder.tests;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Properties;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.Set;
|
||||
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.data.publishing.gCatFeeder.model.CatalogueFormatData;
|
||||
import org.gcube.data.publishing.gCatFeeder.model.InternalConversionException;
|
||||
import org.gcube.data.publishing.gCatfeeder.collectors.CollectorPlugin;
|
||||
|
@ -20,9 +16,9 @@ import org.junit.BeforeClass;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class BaseCollectorTest {
|
||||
public class BaseCollectorTest extends InfrastructureTests{
|
||||
|
||||
|
||||
private static String testContext=null;
|
||||
|
||||
private static final Logger log= LoggerFactory.getLogger(BaseCollectorTest.class);
|
||||
|
||||
|
@ -67,18 +63,11 @@ public class BaseCollectorTest {
|
|||
|
||||
|
||||
// Check if instrastructure is enabled
|
||||
testContext=System.getProperty("testContext");
|
||||
System.out.println("TEST CONTEXT = "+testContext);
|
||||
|
||||
|
||||
|
||||
if(isTestInfrastructureEnabled()) {
|
||||
Properties props=new Properties();
|
||||
try{
|
||||
props.load(BaseCollectorTest.class.getResourceAsStream("/tokens.properties"));
|
||||
}catch(IOException e) {throw new RuntimeException(e);}
|
||||
if(!props.containsKey(testContext)) throw new RuntimeException("No token found for scope : "+testContext);
|
||||
SecurityTokenProvider.instance.set(props.getProperty(testContext));
|
||||
ScopeProvider.instance.set(testContext);
|
||||
|
||||
|
||||
|
||||
for(CollectorPlugin<? extends CustomData> plugin:collectorPluginsLoader) {
|
||||
|
@ -112,8 +101,6 @@ public class BaseCollectorTest {
|
|||
|
||||
|
||||
|
||||
protected static boolean isTestInfrastructureEnabled() {
|
||||
return testContext!=null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
package org.gcube.data.publishing.gCatFeeder.tests;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
public class InfrastructureTests {
|
||||
|
||||
private static String testContext=null;
|
||||
|
||||
static {
|
||||
testContext=System.getProperty("testContext");
|
||||
System.out.println("TEST CONTEXT = "+testContext);
|
||||
}
|
||||
|
||||
protected static boolean isTestInfrastructureEnabled() {
|
||||
return testContext!=null;
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void setTestContext() {
|
||||
|
||||
if(isTestInfrastructureEnabled()) {
|
||||
Properties props=new Properties();
|
||||
try{
|
||||
props.load(BaseCollectorTest.class.getResourceAsStream("/tokens.properties"));
|
||||
}catch(IOException e) {throw new RuntimeException(e);}
|
||||
if(!props.containsKey(testContext)) throw new RuntimeException("No token found for scope : "+testContext);
|
||||
SecurityTokenProvider.instance.set(props.getProperty(testContext));
|
||||
ScopeProvider.instance.set(testContext);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue