Revision 52694
Added by Alessia Bardi over 6 years ago
modules/dnet-data-provision-services/branches/saxonHE/src/main/java/eu/dnetlib/index/actors/IndexFeedActorImpl.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.index.actors; |
2 | 2 |
|
3 |
import java.util.Map; |
|
3 | 4 |
import java.util.concurrent.ExecutorService; |
4 | 5 |
import java.util.concurrent.Executors; |
5 | 6 |
import java.util.function.Function; |
6 | 7 |
|
8 |
import com.google.common.collect.Maps; |
|
7 | 9 |
import eu.dnetlib.clients.index.model.document.IndexDocument; |
8 | 10 |
import eu.dnetlib.clients.index.utils.IndexFieldUtility; |
9 |
import eu.dnetlib.index.utils.IndexDateUtility; |
|
10 |
import eu.dnetlib.utils.MetadataReference; |
|
11 | 11 |
import eu.dnetlib.clients.index.utils.ServiceTools; |
12 |
import eu.dnetlib.cql.CqlTranslator; |
|
12 | 13 |
import eu.dnetlib.enabling.tools.DnetStreamSupport; |
13 | 14 |
import eu.dnetlib.index.IndexCollection; |
14 | 15 |
import eu.dnetlib.index.IndexServerDAO; |
15 | 16 |
import eu.dnetlib.index.IndexServerDAOMap; |
16 |
import eu.dnetlib.cql.CqlTranslator; |
|
17 | 17 |
import eu.dnetlib.index.feed.DocumentFeeder; |
18 | 18 |
import eu.dnetlib.index.feed.DocumentMapperFactory; |
19 | 19 |
import eu.dnetlib.index.feed.FeedMode; |
20 | 20 |
import eu.dnetlib.index.feed.FeedResult; |
21 |
import eu.dnetlib.index.utils.IndexDateUtility; |
|
21 | 22 |
import eu.dnetlib.miscutils.datetime.DateUtils; |
22 | 23 |
import eu.dnetlib.rmi.provision.IndexServiceException; |
24 |
import eu.dnetlib.utils.MetadataReference; |
|
23 | 25 |
import org.apache.commons.logging.Log; |
24 | 26 |
import org.apache.commons.logging.LogFactory; |
25 | 27 |
|
... | ... | |
98 | 100 |
indexCollection.shutdown(); |
99 | 101 |
|
100 | 102 |
log.info("FeedResult: " + res.setTimeElapsed(System.currentTimeMillis())); |
101 |
endCallback.setJobDone(); |
|
103 |
endCallback.setJobDone(buildParams(res));
|
|
102 | 104 |
} catch (final Exception e) { |
103 | 105 |
endCallback.setJobFailed(e); |
104 | 106 |
log.error("feed index job failed", e); |
... | ... | |
110 | 112 |
|
111 | 113 |
} |
112 | 114 |
|
115 |
private Map<String, String> buildParams(final FeedResult feedResult) { |
|
116 |
Map<String, String> params = Maps.newHashMap(); |
|
117 |
params.put("added", String.valueOf(feedResult.getAdded())); |
|
118 |
params.put("skipped", String.valueOf(feedResult.getSkipped())); |
|
119 |
params.put("marked", String.valueOf(feedResult.getMarked())); |
|
120 |
params.put("time", String.valueOf(feedResult.getTime())); |
|
121 |
return params; |
|
122 |
} |
|
123 |
|
|
113 | 124 |
/** |
114 | 125 |
* mdFormatVersion. |
115 | 126 |
* |
modules/dnet-data-provision-services/branches/saxonHE/src/main/java/eu/dnetlib/index/actors/BlackboardActorCallback.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.index.actors; |
2 | 2 |
|
3 |
import java.util.Map; |
|
4 |
|
|
3 | 5 |
public interface BlackboardActorCallback { |
4 | 6 |
|
5 |
void setJobDone(); |
|
7 |
void setJobDone(Map<String, String> params);
|
|
6 | 8 |
|
7 | 9 |
void setJobFailed(Throwable e); |
8 | 10 |
} |
modules/dnet-data-provision-services/branches/saxonHE/src/main/java/eu/dnetlib/index/action/FeedIndexAction.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.index.action; |
2 | 2 |
|
3 |
import java.util.Map; |
|
3 | 4 |
import java.util.UUID; |
4 | 5 |
|
5 | 6 |
import eu.dnetlib.enabling.resultset.client.ResultSetClient; |
... | ... | |
137 | 138 |
return new BlackboardActorCallback() { |
138 | 139 |
|
139 | 140 |
@Override |
140 |
public void setJobDone() { |
|
141 |
public void setJobDone(final Map<String, String> params) {
|
|
141 | 142 |
log.info(job.getAction() + " job set to DONE"); |
142 | 143 |
handler.done(job); |
143 | 144 |
} |
modules/dnet-msro-service/branches/saxonHE/src/test/java/eu/dnetlib/msro/notification/EmailDispatcherTest.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.notification; |
|
2 |
|
|
3 |
/** |
|
4 |
* Created by Alessia Bardi on 03/07/2018. |
|
5 |
* |
|
6 |
* @author Alessia Bardi |
|
7 |
*/ |
|
8 |
public class EmailDispatcherTest { |
|
9 |
|
|
10 |
private transient EmailDispatcher dispatcher = new EmailDispatcher(); |
|
11 |
|
|
12 |
|
|
13 |
} |
modules/dnet-msro-service/branches/saxonHE/src/main/java/eu/dnetlib/msro/workflows/nodes/index/UpdateIndexJobNode.java | ||
---|---|---|
3 | 3 |
import java.io.IOException; |
4 | 4 |
import java.io.StringReader; |
5 | 5 |
import java.io.StringWriter; |
6 |
import java.util.Map; |
|
6 | 7 |
import javax.xml.transform.Transformer; |
7 | 8 |
import javax.xml.transform.TransformerConfigurationException; |
8 | 9 |
import javax.xml.transform.TransformerException; |
... | ... | |
17 | 18 |
import eu.dnetlib.enabling.resultset.factory.ResultSetFactory; |
18 | 19 |
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob; |
19 | 20 |
import eu.dnetlib.msro.workflows.nodes.BlackboardJobNode; |
21 |
import eu.dnetlib.msro.workflows.nodes.blackboard.BlackboardWorkflowJobListener; |
|
20 | 22 |
import eu.dnetlib.msro.workflows.procs.Env; |
21 | 23 |
import eu.dnetlib.msro.workflows.procs.Token; |
22 | 24 |
import eu.dnetlib.msro.workflows.util.ResultsetProgressProvider; |
25 |
import eu.dnetlib.msro.workflows.util.WorkflowsConstants; |
|
23 | 26 |
import eu.dnetlib.rmi.common.ResultSet; |
24 | 27 |
import eu.dnetlib.rmi.common.ResultSetException; |
25 | 28 |
import eu.dnetlib.rmi.enabling.ISLookUpDocumentNotFoundException; |
... | ... | |
135 | 138 |
} |
136 | 139 |
} |
137 | 140 |
|
141 |
@Override |
|
142 |
protected BlackboardWorkflowJobListener generateBlackboardListener(final Token token) { |
|
143 |
return new BlackboardWorkflowJobListener(token) { |
|
144 |
|
|
145 |
@Override |
|
146 |
protected void responseToEnv(final Env env, final Map<String, String> responseParams) { |
|
147 |
env.setAttribute(WorkflowsConstants.MAIN_LOG_PREFIX + "indexed", responseParams.get("added")); |
|
148 |
env.setAttribute(WorkflowsConstants.MAIN_LOG_PREFIX + "skipped", responseParams.get("skipped")); |
|
149 |
env.setAttribute(WorkflowsConstants.MAIN_LOG_PREFIX + "marked", responseParams.get("marked")); |
|
150 |
env.setAttribute(WorkflowsConstants.MAIN_LOG_PREFIX + "time", responseParams.get("time")); |
|
151 |
} |
|
152 |
}; |
|
153 |
} |
|
154 |
|
|
138 | 155 |
// setters and getters |
139 | 156 |
|
140 | 157 |
public String getIndexId() { |
modules/dnet-msro-service/branches/saxonHE/src/main/resources/eu/dnetlib/bootstrap/profiles/default_wf_email.xml | ||
---|---|---|
14 | 14 |
<div> |
15 | 15 |
<p>**** This mail has been generated automatically by D-NET Manager Service, please don't reply ****</p> |
16 | 16 |
<p> |
17 |
<b>Datasource name: </b>$proc.dsName$<br/> |
|
18 |
<b>Datasource id: </b>$proc.dsId$<br/> |
|
19 |
<b>Datasource API: </b>$proc.dsInterface$<br/> |
|
17 | 20 |
<b>Workflow:</b> <a href="$baseUrl$/workflows.do#/wf/$proc.profileId$">$proc.name$</a><br/> |
18 | 21 |
<b>Status:</b> $proc.status$<br/> |
19 | 22 |
<b>Infrastructure:</b> $infrastructure$ |
... | ... | |
23 | 26 |
<b>Workflow details:</b><br /> |
24 | 27 |
<table> |
25 | 28 |
<tr><td>Process ID: </td><td><a href="$baseUrl$/workflow_journal.do?procId=$proc.id$">$proc.id$</a></td></tr> |
26 |
$if(proc.outputParams.attributes)$
|
|
27 |
$proc.outputParams.attributes.keys:{k|<tr><td>$k$: </td><td><i>$proc.outputParams.attributes.(k)$</i></td></tr>}$
|
|
29 |
$if(proc.outputParams)$ |
|
30 |
$proc.outputParams.keys:{k|<tr><td>$k$: </td><td><i>$proc.outputParams.(k)$</i></td></tr>}$
|
|
28 | 31 |
$endif$ |
29 | 32 |
</table> |
33 |
<b>Global params</b> |
|
34 |
<table> |
|
35 |
$if(proc.globalParams)$ |
|
36 |
$proc.globalParams.keys:{k|<tr><td>$k$: </td><td><i>$proc.globalParams.(k)$</i></td></tr>}$ |
|
37 |
$endif$ |
|
38 |
</table> |
|
39 |
<b>Env attributes</b> |
|
40 |
<table> |
|
41 |
$if(proc.env.attributes)$ |
|
42 |
$proc.env.attributes.keys:{k|<tr><td>$k$: </td><td><i>$proc.env.attributes.(k)$</i></td></tr>}$ |
|
43 |
$endif$ |
|
44 |
</table> |
|
45 |
|
|
30 | 46 |
</p> |
31 | 47 |
$if(error)$ |
32 | 48 |
<hr /> |
Also available in: Unified diff
BBActorCallback now can pass parameters back to the workflow for logging purposes.