Project

General

Profile

1
package eu.dnetlib.msro.workflows.nodes.objectStore;
2

    
3
import javax.annotation.Resource;
4

    
5
import eu.dnetlib.data.objectstore.rmi.ObjectStoreService;
6
import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
7
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
8
import eu.dnetlib.miscutils.datetime.DateUtils;
9
import eu.dnetlib.msro.workflows.graph.Arc;
10
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode;
11
import eu.dnetlib.msro.workflows.procs.Env;
12

    
13
// TODO: Auto-generated Javadoc
14

    
15
/**
16
 * The Class UpdateObjectStoreSizeJobNode.
17
 */
18
public class UpdateObjectStoreSizeJobNode extends SimpleJobNode {
19

    
20
	/**
21
	 * The object store id.
22
	 */
23
	private String objectStoreIdParam;
24

    
25
	/**
26
	 * The service locator.
27
	 */
28
	@Resource
29
	private UniqueServiceLocator serviceLocator;
30

    
31
	@Override
32
	protected String execute(final Env env) throws Exception {
33

    
34
		final ISRegistryService registry = serviceLocator.getService(ISRegistryService.class);
35

    
36
		int size = serviceLocator.getService(ObjectStoreService.class, objectStoreIdParam).getSize(objectStoreIdParam);
37

    
38
		String now = DateUtils.now_ISO8601();
39

    
40
		String mdstoreXUpdate = "for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + objectStoreIdParam + "']"
41
				+ "return update value $x//LAST_STORAGE_DATE with '" + now + "'";
42

    
43
		registry.executeXUpdate(mdstoreXUpdate);
44

    
45
		String mdstoreNumberXUpdate = "for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + objectStoreIdParam + "']"
46
				+ "return update value $x//COUNT_STORE with '" + size + "'";
47

    
48
		registry.executeXUpdate(mdstoreNumberXUpdate);
49

    
50
		mdstoreNumberXUpdate = "for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + objectStoreIdParam + "']"
51
				+ "return update value $x//STORE_SIZE with '" + size + "'";
52

    
53
		registry.executeXUpdate(mdstoreNumberXUpdate);
54

    
55
		return Arc.DEFAULT_ARC;
56
	}
57

    
58
	/**
59
	 * Gets the object store id param.
60
	 *
61
	 * @return the objectStoreIdParam
62
	 */
63
	public String getObjectStoreIdParam() {
64
		return objectStoreIdParam;
65
	}
66

    
67
	/**
68
	 * Sets the object store id param.
69
	 *
70
	 * @param objectStoreIdParam the new object store id param
71
	 */
72
	public void setObjectStoreIdParam(final String objectStoreIdParam) {
73
		this.objectStoreIdParam = objectStoreIdParam;
74
	}
75

    
76
}
(4-4/4)