Project

General

Profile

1
package eu.dnetlib.msro.workflows.dedup;
2

    
3
import org.apache.commons.lang.StringUtils;
4
import org.apache.commons.logging.Log;
5
import org.apache.commons.logging.LogFactory;
6

    
7
import com.googlecode.sarasvati.NodeToken;
8

    
9
import eu.dnetlib.data.proto.DedupSimilarityProtos.DedupSimilarity;
10
import eu.dnetlib.data.proto.RelTypeProtos.RelType;
11
import eu.dnetlib.data.proto.RelTypeProtos.SubRelType;
12
import eu.dnetlib.data.proto.TypeProtos.Type;
13
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
14
import eu.dnetlib.msro.rmi.MSROException;
15

    
16
public class DedupSimilarityToActionsJobNode extends DedupConfigurationAwareJobNode {
17

    
18
	private static final Log log = LogFactory.getLog(DedupSimilarityToActionsJobNode.class); // NOPMD by marko on 11/24/08 5:02 PM
19

    
20
	@Override
21
	protected void prepareJob(final BlackboardJob job, final NodeToken token) throws Exception {
22
		super.prepareJob(job, token);
23

    
24
		final String entityType = token.getEnv().getAttribute("entityType");
25
		if (StringUtils.isBlank(entityType))
26
			throw new MSROException("unable to find wf param: entityType");
27

    
28
		String cf = "_" + SubRelType.dedupSimilarity + "_" + DedupSimilarity.RelName.isSimilarTo;
29
		switch (Type.valueOf(entityType)) {
30

    
31
		case organization:
32
			cf = RelType.organizationOrganization + cf;
33
			break;
34
		case result:
35
			cf = RelType.resultResult + cf;
36
			break;
37
		default:
38
			throw new MSROException("invalid parameter entityType: " + entityType);
39
		}
40

    
41
		log.info("using similarity CF: " + cf);
42
		job.getParameters().put("similarityCF", cf);
43
		token.getEnv().setAttribute("similarityCF", cf);
44
	}
45

    
46
}
(9-9/15)