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