94 lines
2.3 KiB
Java
94 lines
2.3 KiB
Java
package eu.dnetlib.manager.wf.nodes.conf;
|
|
|
|
import java.util.HashMap;
|
|
import java.util.LinkedHashMap;
|
|
import java.util.Map;
|
|
import java.util.UUID;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import eu.dnetlib.dsm.model.Api;
|
|
import eu.dnetlib.dsm.model.Datasource;
|
|
import eu.dnetlib.manager.wf.annotations.WfInputParam;
|
|
import eu.dnetlib.manager.wf.annotations.WfNode;
|
|
import eu.dnetlib.manager.wf.annotations.WfOutputParam;
|
|
import eu.dnetlib.manager.wf.model.WorkflowConfiguration;
|
|
import eu.dnetlib.manager.wf.nodes.AbstractJobNode;
|
|
import eu.dnetlib.manager.wf.repository.WorkflowConfigurationRepository;
|
|
|
|
@WfNode("registerWfConfiguration")
|
|
public class RegisterWfConfigurationNode extends AbstractJobNode {
|
|
|
|
private static final int DEFAULT_AGGR_PRIORITY = 75;
|
|
|
|
@WfInputParam
|
|
private String wfId;
|
|
|
|
@WfInputParam
|
|
private String destroyWfId;
|
|
|
|
@WfInputParam
|
|
private Datasource ds;
|
|
|
|
@WfInputParam
|
|
private Api api;
|
|
|
|
@WfInputParam
|
|
private String nativeMdStoreId;
|
|
|
|
@WfInputParam
|
|
private String cleanedMdStoreId;
|
|
|
|
@WfOutputParam
|
|
private String wfConfId;
|
|
|
|
@Autowired
|
|
private WorkflowConfigurationRepository wfConfigurationRepository;
|
|
|
|
@Override
|
|
protected void execute() throws Exception {
|
|
|
|
wfConfId = "wf-aggr-" + UUID.randomUUID();
|
|
|
|
final WorkflowConfiguration conf = new WorkflowConfiguration();
|
|
conf.setId(wfConfId);
|
|
conf.setSection("aggregator");
|
|
conf.setParentId(null);
|
|
|
|
conf.setName(String.format("Aggregation of '%s' (api: %s) ", ds.getOfficialname(), api.getId()));
|
|
conf.setDetails(new HashMap<>());
|
|
|
|
conf.setDsId(ds.getId());
|
|
conf.setDsName(ds.getOfficialname());
|
|
conf.setApiId(api.getId());
|
|
|
|
conf.setWorkflow(wfId);
|
|
conf.setDestroyWf(destroyWfId);
|
|
conf.setEnabled(true);
|
|
conf.setPriority(DEFAULT_AGGR_PRIORITY);
|
|
|
|
conf.setSchedulingEnabled(false);
|
|
conf.setCronExpression("0 0 0 ? * *");
|
|
conf.setCronMinInterval(10080);
|
|
|
|
conf.setSystemParams(prepareSystemParams());
|
|
|
|
conf.setConfigured(verifyConfiguration());
|
|
|
|
wfConfigurationRepository.save(conf);
|
|
}
|
|
|
|
private Map<String, String> prepareSystemParams() {
|
|
final Map<String, String> map = new LinkedHashMap<>();
|
|
map.put("nativeMdStoreId", nativeMdStoreId);
|
|
map.put("cleanedMdStoreId", cleanedMdStoreId);
|
|
return map;
|
|
}
|
|
|
|
private boolean verifyConfiguration() {
|
|
// TODO Auto-generated method stub
|
|
return false;
|
|
}
|
|
|
|
}
|