93 lines
2.9 KiB
Java
93 lines
2.9 KiB
Java
package org.gcube.data.publishing.gCatFeeder.collectors.dm;
|
|
|
|
import java.nio.file.Files;
|
|
import java.nio.file.Path;
|
|
import java.nio.file.Paths;
|
|
import java.util.Collections;
|
|
import java.util.Set;
|
|
|
|
import org.gcube.data.publishing.gCatFeeder.collectors.dm.model.InternalAlgorithmDescriptor;
|
|
import org.gcube.data.publishing.gCatFeeder.collectors.dm.model.ckan.GCatModel;
|
|
import org.gcube.data.publishing.gCatFeeder.model.CatalogueFormatData;
|
|
import org.gcube.data.publishing.gCatFeeder.model.ControllerConfiguration;
|
|
import org.gcube.data.publishing.gCatFeeder.model.EnvironmentConfiguration;
|
|
import org.gcube.data.publishing.gCatfeeder.collectors.CatalogueRetriever;
|
|
import org.gcube.data.publishing.gCatfeeder.collectors.CollectorPlugin;
|
|
import org.gcube.data.publishing.gCatfeeder.collectors.DataCollector;
|
|
import org.gcube.data.publishing.gCatfeeder.collectors.DataTransformer;
|
|
import org.gcube.data.publishing.gCatfeeder.collectors.model.PluginDescriptor;
|
|
import org.gcube.data.publishing.gCatfeeder.collectors.model.faults.CatalogueNotSupportedException;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
@Slf4j
|
|
public class DataMinerPlugin implements CollectorPlugin<InternalAlgorithmDescriptor> {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
public PluginDescriptor getDescriptor() {
|
|
return new PluginDescriptor(Constants.PLUGIN_ID);
|
|
}
|
|
|
|
@Override
|
|
public CatalogueRetriever getRetrieverByCatalogueType(String catalogueType) throws CatalogueNotSupportedException {
|
|
switch(catalogueType) {
|
|
case Constants.GCAT_TYPE : return GCATRetriever.get();
|
|
default : throw new CatalogueNotSupportedException("No support for "+catalogueType);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public Set<String> getSupportedCatalogueTypes() {
|
|
return Collections.singleton(Constants.GCAT_TYPE);
|
|
}
|
|
|
|
@Override
|
|
public DataCollector<InternalAlgorithmDescriptor> getCollector() {
|
|
return new DMAlgorithmsInfoCollector();
|
|
}
|
|
|
|
@Override
|
|
public DataTransformer<? extends CatalogueFormatData, InternalAlgorithmDescriptor> getTransformerByCatalogueType(
|
|
String catalogueType) throws CatalogueNotSupportedException {
|
|
switch(catalogueType) {
|
|
case Constants.GCAT_TYPE : return new GCATTransformer();
|
|
default : throw new CatalogueNotSupportedException("No support for "+catalogueType);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void init() throws Exception {
|
|
log.debug("Initializing..");
|
|
Path p=Paths.get(this.getClass().getResource( "profile.xml").toURI());
|
|
log.debug("Path is : {} ",p.toUri());
|
|
GCatModel.setProfile(
|
|
new String(Files.readAllBytes(p)));
|
|
|
|
DataMinerCollectorProperties.init();
|
|
|
|
}
|
|
|
|
@Override
|
|
public void initInScope() throws Exception {
|
|
// TODO Auto-generated method stub
|
|
|
|
}
|
|
|
|
@Override
|
|
public ControllerConfiguration getPublisherControllerConfiguration(String catalogueType)
|
|
throws CatalogueNotSupportedException {
|
|
return new ControllerConfiguration();
|
|
}
|
|
|
|
|
|
@Override
|
|
public void setEnvironmentConfiguration(EnvironmentConfiguration env) {
|
|
// TODO Auto-generated method stub
|
|
|
|
}
|
|
}
|