Project

General

Profile

1
package eu.dnetlib.data.mdstore.modular;
2

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

    
6
import eu.dnetlib.data.mdstore.MDStoreServiceException;
7
import eu.dnetlib.data.mdstore.modular.connector.MDStoreTransactionManager;
8
import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
9
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
10
import eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction;
11
import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
12

    
13
public class CreateAction extends AbstractMDStoreAction implements BlackboardServerAction<MDStoreActions> {
14

    
15
	private MDStoreProfileCreator profileCreator;
16

    
17
	@Autowired
18
	private MDStoreTransactionManager transactionManager;
19

    
20
	@Override
21
	public void execute(final BlackboardServerHandler handler, final BlackboardJob job) throws ISRegistryException, MDStoreServiceException {
22
		final String format = job.getParameters().get("format");
23
		final String interpretation = job.getParameters().get("interpretation");
24
		final String layout = job.getParameters().get("layout");
25

    
26
		final String mdId = profileCreator.registerProfile(format, interpretation, layout);
27

    
28
		try {
29
			transactionManager.createMDStore(mdId);
30
		} catch (MDStoreServiceException e) {
31
			throw new ISRegistryException("Error on create mdStore", e);
32
		}
33
		getDao().createMDStore(mdId, format, interpretation, layout);
34

    
35
		job.getParameters().put("id", mdId);
36

    
37
		handler.done(job);
38
	}
39

    
40
	public MDStoreProfileCreator getProfileCreator() {
41
		return profileCreator;
42
	}
43

    
44
	@Required
45
	public void setProfileCreator(final MDStoreProfileCreator profileCreator) {
46
		this.profileCreator = profileCreator;
47
	}
48

    
49
}
(3-3/16)