1
|
package eu.dnetlib.msro.workflows.nodes.objectStore;
|
2
|
|
3
|
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
|
4
|
import eu.dnetlib.miscutils.datetime.DateUtils;
|
5
|
import eu.dnetlib.msro.workflows.graph.Arc;
|
6
|
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode;
|
7
|
import eu.dnetlib.msro.workflows.procs.Env;
|
8
|
import eu.dnetlib.rmi.data.ObjectStoreService;
|
9
|
import eu.dnetlib.rmi.enabling.ISRegistryService;
|
10
|
import org.springframework.beans.factory.annotation.Autowired;
|
11
|
|
12
|
// TODO: Auto-generated Javadoc
|
13
|
|
14
|
/**
|
15
|
* The Class UpdateObjectStoreSizeJobNode.
|
16
|
*/
|
17
|
public class UpdateObjectStoreSizeJobNode extends SimpleJobNode {
|
18
|
|
19
|
/**
|
20
|
* The object store id.
|
21
|
*/
|
22
|
private String objectStoreIdParam;
|
23
|
|
24
|
/**
|
25
|
* The service locator.
|
26
|
*/
|
27
|
@Autowired
|
28
|
private UniqueServiceLocator serviceLocator;
|
29
|
|
30
|
@Override
|
31
|
protected String execute(final Env env) throws Exception {
|
32
|
|
33
|
final ISRegistryService registry = this.serviceLocator.getService(ISRegistryService.class);
|
34
|
|
35
|
final int size = this.serviceLocator.getService(ObjectStoreService.class, this.objectStoreIdParam).getSize(this.objectStoreIdParam);
|
36
|
|
37
|
final String now = DateUtils.now_ISO8601();
|
38
|
|
39
|
final String mdstoreXUpdate = "for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + this.objectStoreIdParam + "']"
|
40
|
+ "return update value $x//LAST_STORAGE_DATE with '" + now + "'";
|
41
|
|
42
|
registry.executeXUpdate(mdstoreXUpdate);
|
43
|
|
44
|
String mdstoreNumberXUpdate = "for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + this.objectStoreIdParam + "']"
|
45
|
+ "return update value $x//COUNT_STORE with '" + size + "'";
|
46
|
|
47
|
registry.executeXUpdate(mdstoreNumberXUpdate);
|
48
|
|
49
|
mdstoreNumberXUpdate = "for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + this.objectStoreIdParam + "']"
|
50
|
+ "return update value $x//STORE_SIZE with '" + size + "'";
|
51
|
|
52
|
registry.executeXUpdate(mdstoreNumberXUpdate);
|
53
|
|
54
|
return Arc.DEFAULT_ARC;
|
55
|
}
|
56
|
|
57
|
/**
|
58
|
* Gets the object store id param.
|
59
|
*
|
60
|
* @return the objectStoreIdParam
|
61
|
*/
|
62
|
public String getObjectStoreIdParam() {
|
63
|
return this.objectStoreIdParam;
|
64
|
}
|
65
|
|
66
|
/**
|
67
|
* Sets the object store id param.
|
68
|
*
|
69
|
* @param objectStoreIdParam
|
70
|
* the new object store id param
|
71
|
*/
|
72
|
public void setObjectStoreIdParam(final String objectStoreIdParam) {
|
73
|
this.objectStoreIdParam = objectStoreIdParam;
|
74
|
}
|
75
|
|
76
|
}
|