2019-03-07 18:01:44 +01:00
|
|
|
package org.gcube.data.publishing.gCatFeeder.collectors.dm;
|
2019-03-06 11:13:28 +01:00
|
|
|
|
|
|
|
import java.util.HashSet;
|
2019-03-14 16:58:03 +01:00
|
|
|
import java.util.List;
|
2019-03-06 11:13:28 +01:00
|
|
|
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;
|
2019-03-07 18:01:44 +01:00
|
|
|
import org.gcube.data.publishing.gCatFeeder.collectors.dm.model.InternalAlgorithmDescriptor;
|
2019-03-07 17:29:38 +01:00
|
|
|
import org.gcube.data.publishing.gCatfeeder.collectors.DataCollector;
|
|
|
|
import org.gcube.data.publishing.gCatfeeder.collectors.model.faults.CollectorFault;
|
2019-03-06 11:13:28 +01:00
|
|
|
|
2019-03-14 16:58:03 +01:00
|
|
|
import lombok.extern.slf4j.Slf4j;
|
2019-03-06 11:13:28 +01:00
|
|
|
|
2019-03-14 16:58:03 +01:00
|
|
|
@Slf4j
|
2019-03-06 11:13:28 +01:00
|
|
|
public class DMAlgorithmsInfoCollector implements DataCollector<InternalAlgorithmDescriptor> {
|
|
|
|
|
2019-03-14 16:58:03 +01:00
|
|
|
|
2019-03-06 11:13:28 +01:00
|
|
|
@Override
|
|
|
|
public Set<InternalAlgorithmDescriptor> collect() throws CollectorFault {
|
|
|
|
try {
|
2019-03-14 16:58:03 +01:00
|
|
|
log.trace("Collecting information for Dataminer algorithms");
|
|
|
|
HashSet<InternalAlgorithmDescriptor> toReturn=new HashSet();
|
|
|
|
SClient client=new DataMinerService().getClient();
|
2019-04-01 15:30:16 +02:00
|
|
|
// client.
|
2019-03-14 16:58:03 +01:00
|
|
|
List<OperatorsClassification> opClassifications=client.getOperatorsClassifications();
|
|
|
|
log.debug("Found {} classifications.",opClassifications.size());
|
2019-03-06 11:13:28 +01:00
|
|
|
|
2019-03-14 16:58:03 +01:00
|
|
|
for(OperatorsClassification opClass: opClassifications) {
|
|
|
|
// Load info
|
|
|
|
String opClassName =opClass.getName();
|
|
|
|
|
2019-03-06 11:13:28 +01:00
|
|
|
|
2019-03-14 16:58:03 +01:00
|
|
|
List<Operator> ops=opClass.getOperators();
|
|
|
|
log.debug("Found {} operators under classification {} ",ops.size(),opClassName);
|
|
|
|
for(Operator op : ops) {
|
|
|
|
|
|
|
|
InternalAlgorithmDescriptor desc=new InternalAlgorithmDescriptor();
|
|
|
|
desc.setClassName(opClassName);
|
|
|
|
|
|
|
|
// OperatorCategory Info
|
|
|
|
OperatorCategory cat = op.getCategory();
|
|
|
|
String categoryBriefDescription = cat.getBriefDescription();
|
|
|
|
String categoryDescription= cat.getDescription();
|
|
|
|
String categoryID=cat.getId();
|
|
|
|
String categoryName=cat.getName();
|
|
|
|
|
|
|
|
|
|
|
|
desc.setCategoryBriefDescription(categoryBriefDescription);
|
|
|
|
desc.setCategoryID(categoryID);
|
|
|
|
desc.setCategoryName(categoryName);
|
|
|
|
desc.setCategoryDescription(categoryDescription);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Operator info
|
|
|
|
|
|
|
|
String opBriefDescription=op.getBriefDescription();
|
|
|
|
String opDescription=op.getDescription();
|
|
|
|
String opID=op.getId();
|
|
|
|
String operatorName=op.getName();
|
|
|
|
|
|
|
|
|
|
|
|
desc.setBriefDescription(opBriefDescription);
|
|
|
|
desc.setDescription(opDescription);
|
|
|
|
desc.setId(opID);
|
|
|
|
desc.setName(operatorName);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Parameters info
|
|
|
|
for(Parameter param:op.getOperatorParameters()) {
|
|
|
|
String paramDescription=param.getDescription();
|
|
|
|
String paramName=param.getName();
|
|
|
|
String paramType=param.getTypology().toString();
|
|
|
|
String paramValue=param.getValue();
|
|
|
|
}
|
|
|
|
|
2019-04-01 15:30:16 +02:00
|
|
|
|
|
|
|
// op.get
|
|
|
|
|
2019-03-14 16:58:03 +01:00
|
|
|
toReturn.add(desc);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Create bean
|
2019-03-06 11:13:28 +01:00
|
|
|
|
|
|
|
|
|
|
|
}
|
2019-03-14 16:58:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return toReturn;
|
2019-03-06 11:13:28 +01:00
|
|
|
}catch(Exception e) {
|
|
|
|
throw new CollectorFault("Unable to retrieve information",e);
|
|
|
|
}
|
|
|
|
}
|
2019-03-14 16:58:03 +01:00
|
|
|
|
2019-03-06 11:13:28 +01:00
|
|
|
}
|