Project

General

Profile

« Previous | Next » 

Revision 62709

Added by Alessia Bardi over 1 year ago

[maven-release-plugin] copy for tag dnet-openaireplus-workflows-8.0.3

View differences:

modules/dnet-openaireplus-workflows/tags/dnet-openaireplus-workflows-8.0.3/src/main/java/eu/dnetlib/msro/openaireplus/workflows/nodes/hostedby/UpsertHostedByApisJobNode.java
1
package eu.dnetlib.msro.openaireplus.workflows.nodes.hostedby;
2

  
3
import java.util.Map.Entry;
4

  
5
import org.apache.commons.logging.Log;
6
import org.apache.commons.logging.LogFactory;
7
import org.springframework.beans.factory.annotation.Autowired;
8

  
9
import com.googlecode.sarasvati.Arc;
10
import com.googlecode.sarasvati.NodeToken;
11

  
12
import eu.dnetlib.enabling.datasources.LocalOpenaireDatasourceManager;
13
import eu.dnetlib.enabling.datasources.common.Api;
14
import eu.dnetlib.enabling.datasources.common.ApiParam;
15
import eu.dnetlib.enabling.datasources.common.DsmException;
16
import eu.dnetlib.miscutils.datetime.DateUtils;
17
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode;
18

  
19
public class UpsertHostedByApisJobNode extends SimpleJobNode {
20

  
21
	private static final Log log = LogFactory.getLog(UpsertHostedByApisJobNode.class);
22

  
23
	private static final String HOSTED_BY_COMPLIANCE = "hostedBy";
24

  
25
	@Autowired
26
	private LocalOpenaireDatasourceManager dsManager;
27

  
28
	private String countersParam;
29
	private String mdId;
30
	public static final String extraFieldsForTotal = "last_aggregation_total";
31
	public static final String extraFieldForDate = "last_aggregation_date";
32
	public static final String extraFieldForMdId = "last_aggregation_mdId";
33

  
34
	@Override
35
	protected String execute(final NodeToken token) throws Exception {
36
		final HostedByCounters counters = (HostedByCounters) token.getEnv().getTransientAttribute(countersParam);
37
		final String date = DateUtils.now_ISO8601();
38
		final String namespacePrefix = token.getEnv().getAttribute("namespacePrefix");
39

  
40
		log.info(counters);
41

  
42
		for (final Entry<String, Integer> e : counters.getCounters().entrySet()) {
43
			updateHostedByApi(e.getKey(), namespacePrefix, date, e.getValue());
44
		}
45

  
46
		return Arc.DEFAULT_ARC;
47
	}
48

  
49
	private void updateHostedByApi(final String dsId,
50
		final String namepsacePrefix,
51
		final String date,
52
		final int size) {
53
		log.info("Verifying hostedBy api in ds: " + dsId);
54
		try {
55

  
56
			for (final Api<ApiParam> iface : dsManager.getApis(dsId)) {
57
				if (HOSTED_BY_COMPLIANCE.equals(iface.getCompatibility())) { return; }
58
			}
59

  
60
			final Api<ApiParam> api = new Api<>();
61
			api.setDatasource(dsId);
62
			api.setId("api_________::" + dsId + "::hostedBy");
63
			api.setCompatibility(HOSTED_BY_COMPLIANCE);
64
			api.setProtocol("UNKNOWN");
65
			api.setContentdescription("metadata");
66
			api.setBaseurl("");
67
			api.setActive(false);
68
			api.setRemovable(true);
69
			dsManager.addApi(api);
70
		} catch (final DsmException e) {
71
			log.warn("Error setting hostedBy api of ds: " + dsId, e);
72
		}
73
	}
74

  
75
	public String getMdId() {
76
		return mdId;
77
	}
78

  
79
	public void setMdId(final String mdId) {
80
		this.mdId = mdId;
81
	}
82

  
83
	public String getCountersParam() {
84
		return countersParam;
85
	}
86

  
87
	public void setCountersParam(final String countersParam) {
88
		this.countersParam = countersParam;
89
	}
90

  
91
}
modules/dnet-openaireplus-workflows/tags/dnet-openaireplus-workflows-8.0.3/src/main/java/eu/dnetlib/msro/openaireplus/workflows/nodes/index/FeedMissingClaimsJobNode.java
1
package eu.dnetlib.msro.openaireplus.workflows.nodes.index;
2

  
3
import java.io.IOException;
4
import java.io.StringReader;
5
import java.util.ArrayList;
6
import java.util.List;
7
import javax.annotation.Resource;
8

  
9
import com.googlecode.sarasvati.Arc;
10
import com.googlecode.sarasvati.NodeToken;
11
import eu.dnetlib.data.index.CloudIndexClient;
12
import eu.dnetlib.data.index.CloudIndexClientFactory;
13
import eu.dnetlib.data.index.CloudIndexClientException;
14
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
15
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
16
import eu.dnetlib.miscutils.functional.xml.ApplyXslt;
17
import eu.dnetlib.msro.rmi.MSROException;
18
import eu.dnetlib.msro.workflows.nodes.AsyncJobNode;
19
import eu.dnetlib.openaire.directindex.api.RecentResultsQueue;
20
import eu.dnetlib.openaire.directindex.utils.OafToIndexRecordFactory;
21

  
22
import org.apache.commons.io.IOUtils;
23
import org.apache.commons.logging.Log;
24
import org.apache.commons.logging.LogFactory;
25
import org.apache.solr.common.SolrInputDocument;
26
import org.dom4j.io.SAXReader;
27
import org.springframework.beans.factory.annotation.Required;
28
import org.springframework.beans.factory.annotation.Value;
29
import org.springframework.core.io.ClassPathResource;
30

  
31
/**
32
 * Created by michele on 15/12/15.
33
 */
34
public class FeedMissingClaimsJobNode extends AsyncJobNode {
35

  
36
    private static final Log log = LogFactory.getLog(FeedMissingClaimsJobNode.class);
37
    public static final int BATCH_SIZE = 1000;
38
    public static final int ATTEMPTS = 3;
39
    public static final int SLEEP_MS_SOLR_CLIENT = 5000;
40
    private RecentResultsQueue queue;
41
    private OafToIndexRecordFactory oafToIndexRecordFactory;
42

  
43
    @Resource
44
    private UniqueServiceLocator serviceLocator;
45

  
46
    @Value(value = "${openaire.api.directindex.findSolrIndexUrl.xquery}")
47
    private ClassPathResource findSolrIndexUrl;
48

  
49
    @Override
50
    protected String execute(final NodeToken nodeToken) throws Exception {
51

  
52
        final String format =
53
                nodeToken.getEnv().hasAttribute("format") ? nodeToken.getEnv().getAttribute("format") : nodeToken.getFullEnv().getAttribute("format");
54
        final String coll = format + "-index-openaire";
55
        final String indexDsId = nodeToken.getEnv().getAttribute("index_id");
56
        final String baseUrl = calculateIndexBaseUrl();
57

  
58
        CloudIndexClient idxClient = null;
59

  
60
        try {
61
            final List<SolrInputDocument> toFeed = new ArrayList<SolrInputDocument>();
62
            final List<String> toDeleteFromCache = new ArrayList<String>();
63

  
64
            final SAXReader reader = new SAXReader();
65
            final ApplyXslt xslt = oafToIndexRecordFactory.newTransformer(format);
66

  
67
            idxClient = CloudIndexClientFactory.newIndexClient(baseUrl, coll, false);
68
            log.info("Starting to feed claims in index collection " + coll);
69
            int count = 0;
70
            for (String record : queue) {
71
                int max_attempts = ATTEMPTS;
72
                count++;
73
                final String id = reader.read(new StringReader(record)).valueOf("//*[local-name() = 'objIdentifier']");
74
                if (log.isDebugEnabled()) {
75
                    log.debug(String.format("Processing record %s, number: %d", id, count));
76
                }
77
                if (isRecordIndexed(idxClient, baseUrl, coll, id, max_attempts)) {
78
                    toDeleteFromCache.add(id);
79
                } else {
80
                    max_attempts = ATTEMPTS;
81
                    toFeed.add(prepareSolrDoc(idxClient, baseUrl, coll, id, record, indexDsId, xslt, max_attempts));
82
                }
83
                if (count % BATCH_SIZE == 0) processLists(idxClient, baseUrl, coll, toFeed, toDeleteFromCache);
84
            }
85
            if (!toFeed.isEmpty() || !toDeleteFromCache.isEmpty()) processLists(idxClient, baseUrl, coll, toFeed, toDeleteFromCache);
86
            log.info(String.format("Finished feeding of claims in index collection %s, total: %d", coll, count));
87

  
88
        } catch (Throwable e) {
89
            log.error("Error feeding missing claims", e);
90
            throw e;
91
        } finally {
92
            if (idxClient != null) {
93
                idxClient.close();
94
            }
95
            log.info("Closed Solr index client");
96
        }
97
        log.info("Now proceeding to Arc.DEFAULT_ARC");
98
        return Arc.DEFAULT_ARC;
99
    }
100

  
101
    protected boolean isRecordIndexed(CloudIndexClient idxClient, String baseUrl, String coll, String id, int attempt) throws IOException, CloudIndexClientException, MSROException, InterruptedException {
102
        try {
103
            return idxClient.isRecordIndexed(id);
104
        } catch (CloudIndexClientException cie) {
105
            log.error(String.format("Error querying for %s, message: %s. Trying again, remaining attempts:", id, cie, attempt));
106
            idxClient = resetCloudIndexClient(idxClient, baseUrl, coll);
107
            if (attempt > 0) return isRecordIndexed(idxClient, baseUrl, coll, id, --attempt);
108
            else {
109
                String msg = String.format("Too many attempts %d to recreate the index client for checking if record %s exists.", ATTEMPTS, id);
110
                log.error(msg);
111
                throw new MSROException(cie);
112
            }
113
        }
114
    }
115

  
116
    protected SolrInputDocument prepareSolrDoc(CloudIndexClient idxClient, String baseUrl, String coll, String recordId, String record, String indexDsId, ApplyXslt xslt, int attempt) throws IOException, CloudIndexClientException, MSROException, InterruptedException {
117
        try {
118
            return idxClient.prepareSolrDocument(record, indexDsId, xslt);
119
        } catch (CloudIndexClientException cie) {
120
            log.error(String.format("Error preparing Solr doc for %s, message: %s. Trying again, remaining attempts:", recordId, cie, attempt));
121
            idxClient = resetCloudIndexClient(idxClient, baseUrl, coll);
122
            if (attempt > 0)
123
                return prepareSolrDoc(idxClient, baseUrl, coll, recordId, record, indexDsId, xslt, --attempt);
124
            else {
125
                String msg = String.format("Too many attempts %d to recreate the index client for preparing SolrDocument for %s", ATTEMPTS, id);
126
                log.error(msg);
127
                throw new MSROException(cie);
128
            }
129
        }
130
    }
131

  
132
    protected void tryToFeed(CloudIndexClient idxClient, String baseUrl, String coll, List<SolrInputDocument> toFeed, int attempt) throws MSROException, IOException, CloudIndexClientException, InterruptedException {
133
        try {
134
            idxClient.feed(toFeed, null);
135
        } catch (CloudIndexClientException cie) {
136
            log.error(String.format("Error feeding Solr in attempt number %d", attempt));
137
            idxClient = resetCloudIndexClient(idxClient, baseUrl, coll);
138
            if (attempt > 0) tryToFeed(idxClient, baseUrl, coll, toFeed, --attempt);
139
            else {
140
                String msg = String.format("Too many attempts %d to recreate the index client for feeding Solr", ATTEMPTS);
141
                log.error(msg);
142
                throw new MSROException(cie);
143
            }
144
        }
145
    }
146

  
147
    private CloudIndexClient resetCloudIndexClient(CloudIndexClient idxClient, String baseUrl, String coll) throws IOException, CloudIndexClientException, InterruptedException {
148
        if (idxClient != null) {
149
            idxClient.close();
150
        }
151
        Thread.sleep(SLEEP_MS_SOLR_CLIENT);
152
        CloudIndexClient newclient = CloudIndexClientFactory.newIndexClient(baseUrl, coll, false);
153
        log.info("Got new CloudIndexClient");
154
        return newclient;
155
    }
156

  
157

  
158
    private void processLists(final CloudIndexClient idxClient, String baseUrl, String coll, final List<SolrInputDocument> toFeed, final List<String> toDeleteFromCache) throws CloudIndexClientException, MSROException, IOException, InterruptedException {
159
        int max_attempts = ATTEMPTS;
160
        tryToFeed(idxClient, baseUrl, coll, toFeed, max_attempts);
161
        queue.remove(toDeleteFromCache);
162
        log.info(String.format("%d claims fed and cache cleaned of %d records", toFeed.size(), toDeleteFromCache.size()));
163
        toFeed.clear();
164
        toDeleteFromCache.clear();
165
        log.info("Cleaned temporary lists");
166
    }
167

  
168
    public RecentResultsQueue getQueue() {
169
        return queue;
170
    }
171

  
172
    @Required
173
    public void setQueue(final RecentResultsQueue queue) {
174
        this.queue = queue;
175
    }
176

  
177
    public OafToIndexRecordFactory getOafToIndexRecordFactory() {
178
        return oafToIndexRecordFactory;
179
    }
180

  
181
    @Required
182
    public void setOafToIndexRecordFactory(final OafToIndexRecordFactory oafToIndexRecordFactory) {
183
        this.oafToIndexRecordFactory = oafToIndexRecordFactory;
184
    }
185

  
186
    private String calculateIndexBaseUrl() throws Exception {
187
        final String query = IOUtils.toString(findSolrIndexUrl.getInputStream());
188
        return serviceLocator.getService(ISLookUpService.class).getResourceProfileByQuery(query);
189
    }
190
}
modules/dnet-openaireplus-workflows/tags/dnet-openaireplus-workflows-8.0.3/src/main/java/eu/dnetlib/msro/openaireplus/workflows/nodes/hostedby/FindHostedByJobNode.java
1
package eu.dnetlib.msro.openaireplus.workflows.nodes.hostedby;
2

  
3
import java.io.StringReader;
4
import javax.xml.ws.wsaddressing.W3CEndpointReference;
5

  
6
import com.googlecode.sarasvati.Arc;
7
import com.googlecode.sarasvati.NodeToken;
8
import eu.dnetlib.enabling.resultset.MappedResultSetFactory;
9
import eu.dnetlib.enabling.resultset.client.ResultSetClientFactory;
10
import eu.dnetlib.enabling.resultset.client.utils.EPRUtils;
11
import eu.dnetlib.miscutils.functional.UnaryFunction;
12
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode;
13
import org.dom4j.Document;
14
import org.dom4j.Element;
15
import org.dom4j.io.SAXReader;
16

  
17
// TODO: Auto-generated Javadoc
18

  
19
/**
20
 * The Class FindHostedByJonbNode.
21
 */
22
public class FindHostedByJobNode extends SimpleJobNode {
23

  
24
	/**
25
	 * The input epr param.
26
	 */
27
	private String inputEprParam;
28

  
29
	/**
30
	 * The output epr param.
31
	 */
32
	private String outputEprParam;
33

  
34
	/**
35
	 * The counters param.
36
	 */
37
	private String countersParam;
38

  
39
	/**
40
	 * The result set client factory.
41
	 */
42
	private ResultSetClientFactory resultSetClientFactory;
43

  
44
	/**
45
	 * The mapped result set factory.
46
	 */
47
	private MappedResultSetFactory mappedResultSetFactory;
48

  
49
	private final String unknown_repo_id = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
50

  
51
	/*
52
	 * (non-Javadoc)
53
	 *
54
	 * @see eu.dnetlib.msro.workflows.nodes.SimpleJobNode#execute(com.googlecode.sarasvati.NodeToken)
55
	 */
56
	@Override
57
	protected String execute(final NodeToken token) throws Exception {
58
		final W3CEndpointReference inputEpr = new EPRUtils().getEpr(token.getEnv().getAttribute(inputEprParam));
59
		final HostedByCounters counters = new HostedByCounters();
60

  
61
		final SAXReader reader = new SAXReader();
62

  
63
		final UnaryFunction<String, String> hostedByMapFunction = new UnaryFunction<String, String>() {
64

  
65
			@Override
66
			public String evaluate(final String input) {
67
				try {
68
					final Document doc = reader.read(new StringReader(input));
69
					final Element node = (Element) doc.selectSingleNode("//*[local-name()='hostedBy']");
70
					if (node != null) {
71
						String hostedById = node.attributeValue("id");
72
						if (!hostedById.equals(unknown_repo_id)) {
73
							counters.increaseCounter(hostedById);
74
						}
75
					}
76
				} catch (Exception e) {
77

  
78
				}
79

  
80
				return input;
81
			}
82
		};
83

  
84
		final W3CEndpointReference epr = mappedResultSetFactory.createMappedResultSet(inputEpr, hostedByMapFunction);
85
		token.getEnv().setAttribute(outputEprParam, epr.toString());
86
		token.getEnv().setTransientAttribute(getCountersParam(), counters);
87

  
88
		return Arc.DEFAULT_ARC;
89
	}
90

  
91
	/**
92
	 * @return the inputEprParam
93
	 */
94
	public String getInputEprParam() {
95
		return inputEprParam;
96
	}
97

  
98
	/**
99
	 * @param inputEprParam the inputEprParam to set
100
	 */
101
	public void setInputEprParam(final String inputEprParam) {
102
		this.inputEprParam = inputEprParam;
103
	}
104

  
105
	/**
106
	 * @return the outputEprParam
107
	 */
108
	public String getOutputEprParam() {
109
		return outputEprParam;
110
	}
111

  
112
	/**
113
	 * @param outputEprParam the outputEprParam to set
114
	 */
115
	public void setOutputEprParam(final String outputEprParam) {
116
		this.outputEprParam = outputEprParam;
117
	}
118

  
119
	/**
120
	 * @return the resultSetClientFactory
121
	 */
122
	public ResultSetClientFactory getResultSetClientFactory() {
123
		return resultSetClientFactory;
124
	}
125

  
126
	/**
127
	 * @param resultSetClientFactory the resultSetClientFactory to set
128
	 */
129
	public void setResultSetClientFactory(final ResultSetClientFactory resultSetClientFactory) {
130
		this.resultSetClientFactory = resultSetClientFactory;
131
	}
132

  
133
	/**
134
	 * @return the mappedResultSetFactory
135
	 */
136
	public MappedResultSetFactory getMappedResultSetFactory() {
137
		return mappedResultSetFactory;
138
	}
139

  
140
	/**
141
	 * @param mappedResultSetFactory the mappedResultSetFactory to set
142
	 */
143
	public void setMappedResultSetFactory(final MappedResultSetFactory mappedResultSetFactory) {
144
		this.mappedResultSetFactory = mappedResultSetFactory;
145
	}
146

  
147
	/**
148
	 * @return the countersParam
149
	 */
150
	public String getCountersParam() {
151
		return countersParam;
152
	}
153

  
154
	/**
155
	 * @param countersParam the countersParam to set
156
	 */
157
	public void setCountersParam(final String countersParam) {
158
		this.countersParam = countersParam;
159
	}
160

  
161
}
modules/dnet-openaireplus-workflows/tags/dnet-openaireplus-workflows-8.0.3/src/main/java/eu/dnetlib/msro/openaireplus/workflows/nodes/index/EntityGrouperConfigurationLoader.java
1
package eu.dnetlib.msro.openaireplus.workflows.nodes.index;
2

  
3
import java.util.List;
4
import javax.annotation.Resource;
5

  
6
import com.google.common.collect.Iterables;
7
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
8
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
9
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
10
import org.apache.commons.logging.Log;
11
import org.apache.commons.logging.LogFactory;
12
import org.springframework.beans.factory.annotation.Required;
13

  
14
public class EntityGrouperConfigurationLoader {
15

  
16
	/**
17
	 * logger.
18
	 */
19
	private static final Log log = LogFactory.getLog(EntityGrouperConfigurationLoader.class); // NOPMD by marko on 11/24/08 5:02 PM
20

  
21
	private String xquery;
22

  
23
	@Resource
24
	private UniqueServiceLocator serviceLocator;
25

  
26
	public String load() throws ISLookUpException {
27

  
28
		log.info("loading EntityGrouperConfigurationDSResourceType: " + getXquery());
29

  
30
		List<String> conf = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(getXquery());
31
		if (conf == null || conf.isEmpty()) { throw new IllegalStateException("unable to read entity grouper configuration profile"); }
32
		if (conf.size() > 1) { throw new IllegalStateException("found more than one EntityGrouperConfigurationDSResourceType"); }
33

  
34
		return Iterables.getOnlyElement(conf).replaceAll("\\s+", " ").trim();
35
	}
36

  
37
	public String getXquery() {
38
		return xquery;
39
	}
40

  
41
	@Required
42
	public void setXquery(final String xquery) {
43
		this.xquery = xquery;
44
	}
45

  
46
}
modules/dnet-openaireplus-workflows/tags/dnet-openaireplus-workflows-8.0.3/src/main/java/eu/dnetlib/msro/openaireplus/workflows/nodes/hostedby/HostedByCounters.java
1
package eu.dnetlib.msro.openaireplus.workflows.nodes.hostedby;
2

  
3
import java.io.StringWriter;
4
import java.util.Map;
5
import java.util.Map.Entry;
6

  
7
import com.google.common.collect.Maps;
8

  
9
public class HostedByCounters {
10

  
11
	private Map<String, Integer> counters = Maps.newHashMap();
12

  
13
	public void increaseCounter(final String dsId) {
14
		int val = counters.containsKey(dsId) ? counters.get(dsId) + 1 : 1;
15
		counters.put(dsId, val);
16
	}
17

  
18
	public Map<String, Integer> getCounters() {
19
		return counters;
20
	}
21

  
22
	@Override
23
	public String toString() {
24
		final StringWriter sw = new StringWriter();
25
		sw.append("\n");
26
		sw.append("**************************************************\n");
27
		for (Entry<String, Integer> e : counters.entrySet()) {
28
			sw.append(e.getKey());
29
			sw.append(" : ");
30
			sw.append(Integer.toString(e.getValue()));
31
			sw.append("\n");
32
		}
33
		sw.append("**************************************************\n");
34
		return sw.toString();
35
	}
36
}
modules/dnet-openaireplus-workflows/tags/dnet-openaireplus-workflows-8.0.3/src/main/java/eu/dnetlib/msro/openaireplus/workflows/nodes/index/FinalizeIndexJobNode.java
1
package eu.dnetlib.msro.openaireplus.workflows.nodes.index;
2

  
3
import com.googlecode.sarasvati.NodeToken;
4
import eu.dnetlib.data.provision.index.rmi.IndexService;
5
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpDocumentNotFoundException;
6
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
7
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
8
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
9
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
10
import eu.dnetlib.functionality.index.solr.feed.InputDocumentFactory;
11
import eu.dnetlib.msro.rmi.MSROException;
12
import eu.dnetlib.msro.workflows.nodes.BlackboardJobNode;
13
import org.apache.commons.lang.StringUtils;
14
import org.apache.commons.logging.Log;
15
import org.apache.commons.logging.LogFactory;
16
import org.springframework.beans.factory.annotation.Autowired;
17

  
18
import static java.lang.String.format;
19

  
20
public class FinalizeIndexJobNode extends BlackboardJobNode {
21

  
22
	private static final Log log = LogFactory.getLog(FinalizeIndexJobNode.class); // NOPMD by marko on 11/24/08 5:02 PM
23

  
24
	@Autowired
25
	private UniqueServiceLocator serviceLocator;
26

  
27
	@Override
28
	protected String obtainServiceId(final NodeToken token) {
29
		return getServiceLocator().getServiceId(IndexService.class);
30
	}
31

  
32
	@Override
33
	protected void prepareJob(final BlackboardJob job, final NodeToken token) throws Exception {
34
		final String indexDsId = getEnvParam(token, "index_id");
35

  
36
		log.info("preparing blackboard job DELETE_BY_QUERY index: " + indexDsId);
37

  
38
		final String backendId = getBackendId(indexDsId);
39
		if (StringUtils.isBlank(backendId))
40
			throw new MSROException("empty index backend Id");
41

  
42
		job.setAction("DELETE_BY_QUERY");
43
		job.getParameters().put("id", indexDsId);
44
		job.getParameters().put("backend_Id", backendId);
45
		job.getParameters().put("query", buildQuery(getEnvParam(token, "index.feed.timestamp")));
46
	}
47

  
48
	private String buildQuery(final String version) {
49
		final String query =
50
				String.format("__dsversion:{* TO %s}", InputDocumentFactory.getParsedDateField(version));
51

  
52
		log.info("delete by query: " + query);
53

  
54
		return query;
55
	}
56

  
57
	private String getEnvParam(final NodeToken token, final String name) throws MSROException {
58
		final String value = token.getEnv().getAttribute(name);
59

  
60
		if (StringUtils.isBlank(value))
61
			throw new MSROException(format("unable to finalize index feeding, cannot find property '%s' in the workflow env.", name));
62

  
63
		return value;
64
	}
65

  
66
	public String getBackendId(final String indexDsId) throws ISLookUpDocumentNotFoundException, ISLookUpException {
67
		return getServiceLocator().getService(ISLookUpService.class).getResourceProfileByQuery(
68
				"//RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value='" + indexDsId + "']//BACKEND/text()");
69
	}
70

  
71
}
modules/dnet-openaireplus-workflows/tags/dnet-openaireplus-workflows-8.0.3/src/main/java/eu/dnetlib/msro/openaireplus/workflows/nodes/repobye/DeleteOpenaireMetaWfJobNode.java
1
package eu.dnetlib.msro.openaireplus.workflows.nodes.repobye;
2

  
3
import org.springframework.beans.factory.annotation.Autowired;
4

  
5
import eu.dnetlib.enabling.datasources.common.LocalDatasourceManager;
6
import eu.dnetlib.msro.workflows.nodes.repobye.DeleteMetaWfJobNode;
7

  
8
public class DeleteOpenaireMetaWfJobNode extends DeleteMetaWfJobNode {
9

  
10
	@Autowired
11
	private LocalDatasourceManager<?, ?> dsManager;
12

  
13
	@Override
14
	protected void setActivationStatus(final String dsId, final String ifaceId, final boolean active) throws Exception {
15
		dsManager.setActive(dsId, ifaceId, active);
16
	}
17
}
modules/dnet-openaireplus-workflows/tags/dnet-openaireplus-workflows-8.0.3/pom.xml
1
<?xml version="1.0" ?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3
	<parent>
4
		<groupId>eu.dnetlib</groupId>
5
		<artifactId>dnet45-parent</artifactId>
6
		<version>1.0.0</version>
7
		<relativePath />
8
	</parent>
9
	<modelVersion>4.0.0</modelVersion>
10
	<groupId>eu.dnetlib</groupId>
11
	<artifactId>dnet-openaireplus-workflows</artifactId>
12
	<packaging>jar</packaging>
13
	<version>8.0.3</version>
14

  
15
	<scm>
16
		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet45/modules/dnet-openaireplus-workflows/tags/dnet-openaireplus-workflows-8.0.3</developerConnection>
17
	</scm>
18
	<dependencies>
19
		<dependency>
20
			<groupId>eu.dnetlib</groupId>
21
			<artifactId>cnr-data-flow-monitoring-core</artifactId>
22
			<version>[3.0.0, 4.0.0)</version>
23
			<exclusions>
24
				<exclusion>
25
					<artifactId>wstx-asl</artifactId>
26
					<groupId>org.codehaus.woodstox</groupId>
27
				</exclusion>
28
			</exclusions>
29
		</dependency>
30
		<dependency>
31
			<groupId>eu.dnetlib</groupId>
32
			<artifactId>cnr-enabling-database-api</artifactId>
33
			<version>[2.0.0,3.0.0)</version>
34
		</dependency>
35
		<dependency>
36
			<groupId>eu.dnetlib</groupId>
37
			<artifactId>cnr-enabling-database-service</artifactId>
38
			<version>[3.0.0,4.0.0)</version>
39
		</dependency>
40
		<dependency>
41
			<groupId>eu.dnetlib</groupId>
42
			<artifactId>dnet-msro-service</artifactId>
43
			<version>[4.0.0,5.0.0)</version>
44
		</dependency>
45
		<dependency>
46
			<groupId>eu.dnetlib</groupId>
47
			<artifactId>cnr-resultset-service</artifactId>
48
			<version>[2.0.0,3.0.0)</version>
49
		</dependency>
50
		<dependency>
51
			<groupId>eu.dnetlib</groupId>
52
			<artifactId>dnet-openaire-datasource-manager</artifactId>
53
			<version>[2.0.0,3.0.0)</version>
54
		</dependency>
55
		<dependency>
56
			<groupId>eu.dnetlib</groupId>
57
			<artifactId>dnet-openaireplus-mapping-utils</artifactId>
58
			<version>[6.3.24,7.0.0)</version>
59
		</dependency>
60
		<dependency>
61
			<groupId>eu.dnetlib</groupId>
62
			<artifactId>dnet-hadoop-service-rmi</artifactId>
63
			<version>[1.0.0,2.0.0)</version>
64
		</dependency>
65

  
66
		<dependency>
67
			<groupId>eu.dnetlib</groupId>
68
			<artifactId>dnet-collector-plugins</artifactId>
69
			<version>[1.0.0,2.0.0)</version>
70
		</dependency>
71

  
72
		<dependency>
73
			<groupId>eu.dnetlib</groupId>
74
			<artifactId>dnet-actionmanager-api</artifactId>
75
			<version>[4.0.0,5.0.0)</version>
76
		</dependency>
77

  
78
		<dependency>
79
			<groupId>eu.dnetlib</groupId>
80
			<artifactId>dnet-oai-common-workflows</artifactId>
81
			<version>[5.0.0,6.0.0)</version>
82
		</dependency>
83
		
84
		<dependency>
85
			<groupId>eu.dnetlib</groupId>
86
			<artifactId>cnr-mongo-mdstore</artifactId>
87
			<version>[7.0.0,8.0.0)</version>
88
			<scope>provided</scope>
89
		</dependency>
90
		
91
		<dependency>
92
			<groupId>eu.dnetlib</groupId>
93
			<artifactId>dnet-modular-objectstore-service</artifactId>
94
			<version>[4.2.1,5.0.0)</version>
95
			<scope>provided</scope>
96
		</dependency>
97

  
98
		<dependency>
99
			<groupId>eu.dnetlib</groupId>
100
			<artifactId>dnet-index-client</artifactId>
101
			<version>[2.3.4,3.0.0)</version>
102
		</dependency>
103

  
104
		<dependency>
105
			<groupId>eu.dnetlib</groupId>
106
			<artifactId>dnet-validator-workflows</artifactId>
107
			<version>[2.0.0,3.0.0)</version>
108
		</dependency>
109

  
110
		<dependency>
111
			<groupId>eu.dnetlib</groupId>
112
			<artifactId>dnet-deduplication</artifactId>
113
			<version>[2.0.0,3.0.0)</version>
114
		</dependency>
115

  
116
		<!-- modular ui and servlet api are here because of the stats controller -->
117
		<dependency>
118
			<groupId>eu.dnetlib</groupId>
119
			<artifactId>dnet-directindex-api</artifactId>
120
			<version>[2.1.13,3.0.0)</version>
121
		</dependency>
122

  
123
		<dependency>
124
			<groupId>org.apache.velocity</groupId>
125
			<artifactId>velocity</artifactId>
126
			<version>1.7</version>
127
			<exclusions>
128
				<exclusion>
129
					<artifactId>antlr</artifactId>
130
					<groupId>antlr</groupId>
131
				</exclusion>
132
			</exclusions>
133
		</dependency>
134
		<dependency>
135
			<groupId>org.apache.velocity</groupId>
136
			<artifactId>velocity-tools</artifactId>
137
			<version>2.0</version>
138
			<exclusions>
139
				<exclusion>
140
					<artifactId>antlr</artifactId>
141
					<groupId>antlr</groupId>
142
				</exclusion>
143
			</exclusions>
144
		</dependency>
145
		<dependency>
146
			<groupId>javax.servlet</groupId>
147
			<artifactId>javax.servlet-api</artifactId>
148
			<version>${javax.servlet.version}</version>
149
			<scope>provided</scope>
150
		</dependency>
151
		<dependency>
152
			<groupId>junit</groupId>
153
			<artifactId>junit</artifactId>
154
			<version>${junit.version}</version>
155
			<scope>test</scope>
156
		</dependency>
157
		<dependency>
158
			<groupId>eu.dnetlib</groupId>
159
			<artifactId>dnet-openaireplus-profiles</artifactId>
160
			<version>[1.0.0,2.0.0)</version>
161
			<scope>test</scope>
162
		</dependency>
163
		<dependency>
164
			<groupId>io.springfox</groupId>
165
			<artifactId>springfox-swagger2</artifactId>
166
			<version>${springfox-version}</version>
167
		</dependency>
168
		<dependency>
169
			<groupId>org.mockito</groupId>
170
			<artifactId>mockito-core</artifactId>
171
			<version>1.9.5</version>
172
		</dependency>
173
		<dependency>
174
			<groupId>org.springframework</groupId>
175
			<artifactId>spring-jdbc</artifactId>
176
			<version>${spring.version}</version>
177
		</dependency>
178

  
179
		<dependency>
180
			<groupId>eu.dnetlib</groupId>
181
			<artifactId>cnr-misc-utils</artifactId>
182
			<version>[1.0.5, 2.0.0)</version>
183
		</dependency>
184

  
185

  
186
		<dependency>
187
			<groupId>eu.dnetlib.dhp</groupId>
188
			<artifactId>dhp-common</artifactId>
189
			<version>1.2.4-branch_hadoop_aggregator</version>
190
			<exclusions>
191
				<exclusion>
192
					<groupId>net.sf.saxon</groupId>
193
					<artifactId>Saxon-HE</artifactId>
194
				</exclusion>
195
			</exclusions>
196
		</dependency>
197
	</dependencies>
198

  
199
	<properties>
200
		<springfox-version>2.5.0</springfox-version>
201
	</properties>
202
</project>
modules/dnet-openaireplus-workflows/tags/dnet-openaireplus-workflows-8.0.3/src/main/java/eu/dnetlib/msro/openaireplus/workflows/nodes/repohi/UpdateOpenaireMetaWfStatusJobNode.java
1
package eu.dnetlib.msro.openaireplus.workflows.nodes.repohi;
2

  
3
import org.springframework.beans.factory.annotation.Autowired;
4

  
5
import eu.dnetlib.enabling.datasources.common.LocalDatasourceManager;
6
import eu.dnetlib.msro.workflows.nodes.repohi.UpdateMetaWfStatusJobNode;
7

  
8
public class UpdateOpenaireMetaWfStatusJobNode extends UpdateMetaWfStatusJobNode {
9

  
10
	@Autowired
11
	private LocalDatasourceManager<?, ?> dsManager;
12

  
13
	@Override
14
	protected void updateDatasource(final String dsId, final String ifaceId) throws Exception {
15
		if (!dsId.equals("openaire____::bootstrap")) {
16
			dsManager.setManaged(dsId, true);
17
			dsManager.setActive(dsId, ifaceId, true);
18
		}
19
	}
20

  
21
}
modules/dnet-openaireplus-workflows/tags/dnet-openaireplus-workflows-8.0.3/src/main/java/eu/dnetlib/msro/openaireplus/workflows/nodes/index/FindSearchServicesJobNode.java
1
package eu.dnetlib.msro.openaireplus.workflows.nodes.index;
2

  
3
import java.util.List;
4
import java.util.Queue;
5
import javax.annotation.Resource;
6

  
7
import com.google.common.collect.Queues;
8
import com.googlecode.sarasvati.NodeToken;
9
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
10
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
11
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
12
import eu.dnetlib.msro.rmi.MSROException;
13
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode;
14
import org.apache.commons.logging.Log;
15
import org.apache.commons.logging.LogFactory;
16
import org.springframework.beans.factory.annotation.Value;
17

  
18
/**
19
 * Supercedes eu.dnetlib.msro.openaireplus.workflows.nodes.index.FindSearchServiceJobNode.
20
 * Returns a queue of SearchService ids that match the xquery and saves it in the env with the name 'searchService_ids'.
21
 * Use with eu.dnetlib.msro.openaireplus.workflows.nodes.index.SwitchIndexesJobNode
22
 *
23
 * @author claudio, alessia
24
 */
25
public class FindSearchServicesJobNode extends SimpleJobNode {
26

  
27
	/**
28
	 * logger.
29
	 */
30
	private static final Log log = LogFactory.getLog(FindSearchServicesJobNode.class); // NOPMD by marko on 11/24/08 5:02 PM
31

  
32
	@Resource
33
	private UniqueServiceLocator serviceLocator;
34

  
35
	@Value(value = "${dnet.openaire.service.search.lookup.xquery}")
36
	private String xquery;
37

  
38
	/**
39
	 * {@inheritDoc}
40
	 *
41
	 * @throws ISLookUpException
42
	 * @throws MSROException
43
	 * @see com.googlecode.sarasvati.mem.MemNode#execute(com.googlecode.sarasvati.Engine, NodeToken)
44
	 */
45
	@Override
46
	public String execute(final NodeToken token) throws ISLookUpException, MSROException {
47

  
48
		log.info("lookup for search service: " + getXquery());
49

  
50
		List<String> searchServiceIds = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(getXquery());
51
		log.info("SearchService found: " + searchServiceIds.size());
52
		Queue<String> q = Queues.newLinkedBlockingQueue(searchServiceIds);
53

  
54
		if (searchServiceIds.isEmpty()) {
55
			return "notFound";
56
		} else {
57
			token.getEnv().setTransientAttribute("searchService_ids", q);
58
			return "found";
59
		}
60
	}
61

  
62
	public String getXquery() {
63
		return xquery;
64
	}
65

  
66
	public void setXquery(final String xquery) {
67
		this.xquery = xquery;
68
	}
69
}
modules/dnet-openaireplus-workflows/tags/dnet-openaireplus-workflows-8.0.3/src/main/java/eu/dnetlib/msro/openaireplus/workflows/nodes/PrepareIISParamsV2.java
1
package eu.dnetlib.msro.openaireplus.workflows.nodes;
2

  
3
import java.util.List;
4
import java.util.NoSuchElementException;
5
import javax.annotation.Resource;
6

  
7
import com.google.common.base.Joiner;
8
import com.google.common.base.Splitter;
9
import com.google.common.collect.Iterables;
10
import com.google.common.collect.Lists;
11
import com.googlecode.sarasvati.NodeToken;
12
import eu.dnetlib.data.hadoop.config.ClusterName;
13
import eu.dnetlib.data.hadoop.config.ConfigurationEnumerator;
14
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
15
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
16
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
17
import eu.dnetlib.msro.rmi.MSROException;
18
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode;
19
import org.apache.commons.logging.Log;
20
import org.apache.commons.logging.LogFactory;
21
import org.apache.hadoop.conf.Configuration;
22
import org.springframework.beans.factory.annotation.Required;
23

  
24
public abstract class PrepareIISParamsV2 extends SimpleJobNode {
25

  
26
	private static final Log log = LogFactory.getLog(PrepareIISParamsV2.class);
27

  
28
	@Resource
29
	protected ConfigurationEnumerator configurationEnumerator;
30

  
31
	@Resource
32
	private UniqueServiceLocator serviceLocator;
33

  
34
	private String clusterName;
35

  
36
	private String clusterParam = "cluster";
37

  
38
	private String oozieWfAppPath;
39

  
40
	private String oozieWfAppPathParam = "oozie.wf.application.path";
41

  
42
	private String xqueryMdStoreService;
43

  
44
	private String mdStoreStoreLocationParam = "import_mdstore_service_location";
45

  
46
	private String xqueryObjectStoreService;
47

  
48
	private String objectStoreLocationParam = "import_content_object_store_location";
49

  
50
	private String xqueryIsLookupService;
51

  
52
	private String islookupLocationParam = "import_islookup_service_location";
53

  
54
	private String importProjectConceptsContextCSVParam = "import_project_concepts_context_ids_csv";
55

  
56
	private String importProjectConceptsContextCSV;
57

  
58
	private String importServicesCollectedFromParam = "import_infospace_eligible_service_collectedfrom_datasourceid";
59

  
60
	private String importServicesCollectedFrom;
61

  
62
	private String xqueryDatasetStore;
63

  
64
	private String mdStoreDatasetParam = "import_dataset_mdstore_ids_csv";
65

  
66
	private String objectStoreBlacklistCSV = "";
67

  
68
	protected void prepare(final NodeToken token) throws Exception {
69

  
70
		token.getEnv().setAttribute(getClusterParam(), getClusterName());
71

  
72
		// Assumes we only have one mdStore service instance
73
		token.getEnv().setAttribute(getMdStoreStoreLocationParam(), getServiceEndpoint(getXqueryMdStoreService()));
74
		// Assumes we only have one objectStore service instance
75
		token.getEnv().setAttribute(getObjectStoreLocationParam(), getServiceEndpoint(getXqueryObjectStoreService()));
76

  
77
		token.getEnv().setAttribute(getIslookupLocationParam(), getServiceEndpoint(getXqueryIsLookupService()));
78
		token.getEnv().setAttribute(getImportProjectConceptsContextCSVParam(), getImportProjectConceptsContextCSV());
79
		token.getEnv().setAttribute(getImportServicesCollectedFromParam(), getImportServicesCollectedFrom());
80

  
81
		Configuration conf = configurationEnumerator.get(ClusterName.valueOf(getClusterName()));
82
		String nameNode = conf.get("fs.defaultFS");
83

  
84
		token.getEnv().setAttribute(getOozieWfAppPathParam(), getURI(nameNode, getOozieWfAppPath()));
85
		token.getEnv().setAttribute(getMdStoreDatasetParam(), asCSV(getProfileIds(getXqueryDatasetStore())));
86
	}
87

  
88
	protected String getServiceEndpoint(final String xquery) throws MSROException {
89
		try {
90
			return Iterables.getOnlyElement(serviceLocator.getService(ISLookUpService.class).quickSearchProfile(xquery));
91
		} catch (ISLookUpException e) {
92
			throw new MSROException("unable to fetch service endpoint", e);
93
		} catch (NoSuchElementException e) {
94
			throw new MSROException("unable to find service endpoint, xquery: " + getXqueryMdStoreService(), e);
95
		} catch (IllegalArgumentException e) {
96
			throw new MSROException("more than one services found, we assume to have only one available", e);
97
		}
98
	}
99

  
100
	protected String getProfileId(final String xquery) throws MSROException {
101
		try {
102
			return Iterables.getOnlyElement(serviceLocator.getService(ISLookUpService.class).quickSearchProfile(xquery));
103
		} catch (ISLookUpException e) {
104
			throw new MSROException("unable to fetch profile id", e);
105
		} catch (NoSuchElementException e) {
106
			throw new MSROException("unable to find profile profile, xquery: " + xquery, e);
107
		} catch (IllegalArgumentException e) {
108
			throw new MSROException("more than one profile profiles was found, we assume to have only one available, xquery: " + xquery, e);
109
		}
110
	}
111

  
112
	protected List<String> getProfileIds(final String xquery) throws MSROException {
113
		try {
114
			List<String> ids = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(xquery);
115

  
116
			if (ids.isEmpty()) {
117
				log.warn("couldn't find any profile, xquery: " + xquery);
118
			}
119

  
120
			return ids;
121
		} catch (ISLookUpException e) {
122
			throw new MSROException("unable to fetch profile ids, x query: " + xquery, e);
123
		}
124
	}
125

  
126
	protected String getFilteredObjectStoreCSV(final String xquery) throws MSROException {
127
		return asCSV(filter(getProfileIds(xquery), asList(getObjectStoreBlacklistCSV())));
128
	}
129

  
130
	protected List<String> filter(final List<String> list, final List<String> filter) {
131
		if (filter == null || filter.isEmpty()) { return list; }
132
		list.removeAll(filter);
133
		return list;
134
	}
135

  
136
	protected String asCSV(final List<String> list) {
137
		return Joiner.on(",").skipNulls().join(list);
138
	}
139

  
140
	protected List<String> asList(final String csv) {
141
		return Lists.newArrayList(Splitter.on(",").trimResults().omitEmptyStrings().split(csv));
142
	}
143

  
144
	private String getURI(final String nameNode, final String relative) {
145
		// TODO ensure to return a valid URI
146
		return nameNode + relative;
147
	}
148

  
149
	private String getZkQuorumCSV(final Configuration conf, final String zkPort) {
150
		return Joiner.on(":" + zkPort + ",").join(Splitter.on(",").omitEmptyStrings().split(conf.get("hbase.zookeeper.quorum")));
151
	}
152

  
153
	@Required
154
	public void setXqueryMdStoreService(final String xqueryMdStoreService) {
155
		this.xqueryMdStoreService = xqueryMdStoreService;
156
	}
157

  
158
	public String getXqueryMdStoreService() {
159
		return xqueryMdStoreService;
160
	}
161

  
162
	public String getMdStoreStoreLocationParam() {
163
		return mdStoreStoreLocationParam;
164
	}
165

  
166
	public void setMdStoreStoreLocationParam(final String mdStoreStoreLocationParam) {
167
		this.mdStoreStoreLocationParam = mdStoreStoreLocationParam;
168
	}
169

  
170
	public String getClusterName() {
171
		return clusterName;
172
	}
173

  
174
	public void setClusterName(final String clusterName) {
175
		this.clusterName = clusterName;
176
	}
177

  
178
	public String getClusterParam() {
179
		return clusterParam;
180
	}
181

  
182
	public void setClusterParam(final String clusterParam) {
183
		this.clusterParam = clusterParam;
184
	}
185

  
186
	public String getOozieWfAppPathParam() {
187
		return oozieWfAppPathParam;
188
	}
189

  
190
	public void setOozieWfAppPathParam(final String oozieWfAppPathParam) {
191
		this.oozieWfAppPathParam = oozieWfAppPathParam;
192
	}
193

  
194
	public String getOozieWfAppPath() {
195
		return oozieWfAppPath;
196
	}
197

  
198
	public void setOozieWfAppPath(final String oozieWfAppPath) {
199
		this.oozieWfAppPath = oozieWfAppPath;
200
	}
201

  
202
	@Required
203
	public String getXqueryDatasetStore() {
204
		return xqueryDatasetStore;
205
	}
206

  
207
	public void setXqueryDatasetStore(final String xqueryDatasetStore) {
208
		this.xqueryDatasetStore = xqueryDatasetStore;
209
	}
210

  
211
	public String getMdStoreDatasetParam() {
212
		return mdStoreDatasetParam;
213
	}
214

  
215
	public void setMdStoreDatasetParam(final String mdStoreDatasetParam) {
216
		this.mdStoreDatasetParam = mdStoreDatasetParam;
217
	}
218

  
219
	public String getXqueryObjectStoreService() {
220
		return xqueryObjectStoreService;
221
	}
222

  
223
	@Required
224
	public void setXqueryObjectStoreService(final String xqueryObjectStoreService) {
225
		this.xqueryObjectStoreService = xqueryObjectStoreService;
226
	}
227

  
228
	public String getObjectStoreLocationParam() {
229
		return objectStoreLocationParam;
230
	}
231

  
232
	public void setObjectStoreLocationParam(final String objectStoreLocationParam) {
233
		this.objectStoreLocationParam = objectStoreLocationParam;
234
	}
235

  
236
	public String getObjectStoreBlacklistCSV() {
237
		return objectStoreBlacklistCSV;
238
	}
239

  
240
	public void setObjectStoreBlacklistCSV(final String objectStoreBlacklistCSV) {
241
		this.objectStoreBlacklistCSV = objectStoreBlacklistCSV;
242
	}
243

  
244
	public String getXqueryIsLookupService() {
245
		return xqueryIsLookupService;
246
	}
247

  
248
	@Required
249
	public void setXqueryIsLookupService(final String xqueryIsLookupService) {
250
		this.xqueryIsLookupService = xqueryIsLookupService;
251
	}
252

  
253
	public String getIslookupLocationParam() {
254
		return islookupLocationParam;
255
	}
256

  
257
	public void setIslookupLocationParam(final String islookupLocationParam) {
258
		this.islookupLocationParam = islookupLocationParam;
259
	}
260

  
261
	public String getImportProjectConceptsContextCSVParam() {
262
		return importProjectConceptsContextCSVParam;
263
	}
264

  
265
	public void setImportProjectConceptsContextCSVParam(final String importProjectConceptsContextCSVParam) {
266
		this.importProjectConceptsContextCSVParam = importProjectConceptsContextCSVParam;
267
	}
268

  
269
	public String getImportProjectConceptsContextCSV() {
270
		return importProjectConceptsContextCSV;
271
	}
272

  
273
	public void setImportProjectConceptsContextCSV(final String importProjectConceptsContextCSV) {
274
		this.importProjectConceptsContextCSV = importProjectConceptsContextCSV;
275
	}
276

  
277
	public String getImportServicesCollectedFromParam() {
278
		return importServicesCollectedFromParam;
279
	}
280

  
281
	public void setImportServicesCollectedFromParam(String importServicesCollectedFromParam) {
282
		this.importServicesCollectedFromParam = importServicesCollectedFromParam;
283
	}
284

  
285
	public String getImportServicesCollectedFrom() {
286
		return importServicesCollectedFrom;
287
	}
288

  
289
	public void setImportServicesCollectedFrom(String importServicesCollectedFrom) {
290
		this.importServicesCollectedFrom = importServicesCollectedFrom;
291
	}
292
}
modules/dnet-openaireplus-workflows/tags/dnet-openaireplus-workflows-8.0.3/src/main/java/eu/dnetlib/msro/openaireplus/workflows/nodes/contexts/ProcessContextsJobNode.java
1
package eu.dnetlib.msro.openaireplus.workflows.nodes.contexts;
2

  
3
import javax.annotation.Resource;
4

  
5
import com.googlecode.sarasvati.Arc;
6
import com.googlecode.sarasvati.NodeToken;
7
import eu.dnetlib.enabling.resultset.client.ResultSetClientFactory;
8
import eu.dnetlib.msro.workflows.nodes.ProgressJobNode;
9
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode;
10
import eu.dnetlib.msro.workflows.resultset.ProcessCountingResultSetFactory;
11
import eu.dnetlib.msro.workflows.util.ProgressProvider;
12
import eu.dnetlib.msro.workflows.util.ResultsetProgressProvider;
13
import org.apache.commons.logging.Log;
14
import org.apache.commons.logging.LogFactory;
15

  
16
public class ProcessContextsJobNode extends SimpleJobNode implements ProgressJobNode {
17

  
18
	private static final Log log = LogFactory.getLog(ProcessContextsJobNode.class);
19

  
20
	private String eprParam;
21
	private String contextObj;
22
	private ResultsetProgressProvider progressProvider;
23
	private String contextId;
24
	private String contextLabel;
25
	private String contextType;
26

  
27
	private String contextParams;
28
	private String dashboardVisibility;
29

  
30
	@Resource
31
	private ResultSetClientFactory resultSetClientFactory;
32

  
33
	@Resource
34
	private ProcessCountingResultSetFactory processCountingResultSetFactory;
35

  
36
	@Override
37
	protected String execute(final NodeToken token) throws Exception {
38

  
39
		final String epr = token.getEnv().getAttribute(eprParam);
40

  
41
		this.progressProvider = processCountingResultSetFactory.createProgressProvider(token.getProcess(), epr);
42

  
43
		final Iterable<String> iter = resultSetClientFactory.getClient(progressProvider.getEpr());
44

  
45
		final ContextDesc context = ContextUtils.getContext(iter, getContextId(), getContextLabel(), getContextType(), getContextParams(), getDashboardVisibility());
46

  
47
		token.getEnv().setTransientAttribute(contextObj, context);
48

  
49
		return Arc.DEFAULT_ARC;
50
	}
51

  
52
	public String getEprParam() {
53
		return eprParam;
54
	}
55

  
56
	public void setEprParam(final String eprParam) {
57
		this.eprParam = eprParam;
58
	}
59

  
60
	public String getContextObj() {
61
		return contextObj;
62
	}
63

  
64
	public void setContextObj(final String contextObj) {
65
		this.contextObj = contextObj;
66
	}
67

  
68
	@Override
69
	public ProgressProvider getProgressProvider() {
70
		return progressProvider;
71
	}
72

  
73
	public String getContextId() {
74
		return contextId;
75
	}
76

  
77
	public void setContextId(final String contextId) {
78
		this.contextId = contextId;
79
	}
80

  
81
	public String getContextLabel() {
82
		return contextLabel;
83
	}
84

  
85
	public void setContextLabel(final String contextLabel) {
86
		this.contextLabel = contextLabel;
87
	}
88

  
89
	public String getContextType() {
90
		return contextType;
91
	}
92

  
93
	public void setContextType(final String contextType) {
94
		this.contextType = contextType;
95
	}
96

  
97
	public String getContextParams() {
98
		return contextParams;
99
	}
100

  
101
	public void setContextParams(final String contextParams) {
102
		this.contextParams = contextParams;
103
	}
104

  
105
	public String getDashboardVisibility() {
106
		return dashboardVisibility;
107
	}
108

  
109
	public void setDashboardVisibility(final String dashboardVisibility) {
110
		this.dashboardVisibility = dashboardVisibility;
111
	}
112
}
modules/dnet-openaireplus-workflows/tags/dnet-openaireplus-workflows-8.0.3/src/main/java/eu/dnetlib/msro/openaireplus/workflows/nodes/contexts/ContextPart.java
1
package eu.dnetlib.msro.openaireplus.workflows.nodes.contexts;
2

  
3
import java.util.Map;
4
import java.util.Map.Entry;
5

  
6
import com.google.common.collect.Maps;
7
import org.dom4j.DocumentHelper;
8
import org.dom4j.Element;
9

  
10
public class ContextPart {
11

  
12
	private String id;
13
	private String label;
14
	private Map<String, String> params = Maps.newLinkedHashMap();
15
	private Map<String, ContextPart> parts = Maps.newLinkedHashMap();
16

  
17
	public ContextPart() {
18
	}
19

  
20
	public ContextPart(final String id, final String label) {
21
		this.id = id;
22
		this.label = label;
23
	}
24

  
25
	public String getId() {
26
		return id;
27
	}
28

  
29
	public void setId(final String id) {
30
		this.id = id;
31
	}
32

  
33
	public String getLabel() {
34
		return label;
35
	}
36

  
37
	public void setLabel(final String label) {
38
		this.label = label;
39
	}
40

  
41
	public Map<String, String> getParams() {
42
		return params;
43
	}
44

  
45
	public void setParams(final Map<String, String> params) {
46
		this.params = params;
47
	}
48

  
49
	public Map<String, ContextPart> getParts() {
50
		return parts;
51
	}
52

  
53
	public void setParts(final Map<String, ContextPart> parts) {
54
		this.parts = parts;
55
	}
56

  
57
	public void addPart(final ContextPart part) {
58
		if (parts.containsKey(part.getId())) {
59
			final ContextPart localChild = getParts().get(part.getId());
60
			for (ContextPart child : part.getParts().values()) {
61
				localChild.addPart(child);
62
			}
63
		} else {
64
			parts.put(part.getId(), part);
65
		}
66
	}
67

  
68
	public Element asDomElement(final String name) {
69
		final Element elem = DocumentHelper.createElement(name);
70
		elem.addAttribute("id", id);
71
		elem.addAttribute("label", label);
72
		elem.addAttribute("claim", "false");
73
		for (Entry<String, String> e : params.entrySet()) {
74
			final Element p = elem.addElement("param");
75
			p.addAttribute("name", e.getKey());
76
			p.setText(e.getValue());
77
		}
78
		for (ContextPart child : parts.values()) {
79
			elem.add(child.asDomElement("concept"));
80
		}
81
		return elem;
82
	}
83
}
modules/dnet-openaireplus-workflows/tags/dnet-openaireplus-workflows-8.0.3/src/main/java/eu/dnetlib/msro/openaireplus/workflows/nodes/index/PrepareIndexDataJobNode.java
1
package eu.dnetlib.msro.openaireplus.workflows.nodes.index;
2

  
3
import java.io.IOException;
4
import java.io.InputStream;
5
import java.io.StringReader;
6
import java.io.StringWriter;
7
import javax.annotation.Resource;
8
import javax.xml.transform.Transformer;
9
import javax.xml.transform.TransformerException;
10
import javax.xml.transform.TransformerFactory;
11
import javax.xml.transform.stream.StreamResult;
12
import javax.xml.transform.stream.StreamSource;
13

  
14
import com.googlecode.sarasvati.Arc;
15
import com.googlecode.sarasvati.NodeToken;
16
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpDocumentNotFoundException;
17
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
18
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
19
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
20
import eu.dnetlib.miscutils.datetime.DateUtils;
21
import eu.dnetlib.miscutils.functional.hash.Hashing;
22
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode;
23
import org.apache.commons.io.IOUtils;
24
import org.apache.commons.lang.StringUtils;
25
import org.apache.commons.logging.Log;
26
import org.apache.commons.logging.LogFactory;
27
import org.springframework.beans.factory.annotation.Required;
28
import org.springframework.core.io.ClassPathResource;
29

  
30
public class PrepareIndexDataJobNode extends SimpleJobNode {
31

  
32
	/**
33
	 * logger.
34
	 */
35
	private static final Log log = LogFactory.getLog(PrepareIndexDataJobNode.class); // NOPMD by marko on 11/24/08 5:02 PM
36

  
37
	@Resource
38
	private UniqueServiceLocator serviceLocator;
39

  
40
	/**
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff