Revision 47197
Added by Alessia Bardi almost 7 years ago
X3MTransformJobNode.java | ||
---|---|---|
42 | 42 |
private String outputEprParam; |
43 | 43 |
|
44 | 44 |
private String mappingPolicyProfileId; |
45 |
private String mappingProfileId; |
|
45 |
private String mappingProfileIds;
|
|
46 | 46 |
|
47 | 47 |
private boolean verboseLogging; |
48 | 48 |
|
... | ... | |
61 | 61 |
|
62 | 62 |
@Override |
63 | 63 |
protected String execute(final Env env) throws Exception { |
64 |
log.info("Mapping profile id: " + mappingProfileId);
|
|
64 |
log.info("Mapping profile ids: " + mappingProfileIds);
|
|
65 | 65 |
log.info("Mapping Policy profile id: " + mappingPolicyProfileId); |
66 |
final String mapping = getProfileCode(mappingProfileId);
|
|
66 |
final String[] mappings = getMappingsCode(mappingProfileIds.split(","));
|
|
67 | 67 |
final String policy = getProfileCode(mappingPolicyProfileId); |
68 | 68 |
|
69 | 69 |
LocalDateTime now = LocalDateTime.now(); |
... | ... | |
84 | 84 |
String provenanceFooter = extractFromRecord(record, xpathSelectorFooter); |
85 | 85 |
Instant endExtraction = Instant.now(); |
86 | 86 |
|
87 |
ApplyX3Mapping mappingFunction = new ApplyX3Mapping(mapping, policy, verboseLogging); |
|
87 |
ApplyX3Mapping mappingFunction = new ApplyX3Mapping(mappings, policy, verboseLogging);
|
|
88 | 88 |
|
89 | 89 |
Instant startTransform = Instant.now(); |
90 | 90 |
String transformed = mappingFunction.apply(metadata); |
... | ... | |
103 | 103 |
return Arc.DEFAULT_ARC; |
104 | 104 |
} |
105 | 105 |
|
106 |
private String[] getMappingsCode(String[] mappingIds) throws ISLookUpException { |
|
107 |
String[] mappings = new String[mappingIds.length]; |
|
108 |
for(int i =0; i < mappingIds.length; i++){ |
|
109 |
mappings[i] = getProfileCode(mappingIds[i]); |
|
110 |
} |
|
111 |
return mappings; |
|
112 |
} |
|
113 |
|
|
106 | 114 |
protected String buildXML(String header, String transformationDate, String metadata, String provenance) { |
107 | 115 |
Instant start = Instant.now(); |
108 | 116 |
try { |
... | ... | |
166 | 174 |
String xquery = "string(collection('/db/DRIVER/TransformationRuleDSResources')//RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value ='" + |
167 | 175 |
profId + "']//CODE)"; |
168 | 176 |
List<String> res = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(xquery); |
169 |
if (res.isEmpty()) { |
|
177 |
if (res.isEmpty() || StringUtils.isBlank(res.get(0))) {
|
|
170 | 178 |
throw new RuntimeException("Can't find transformation rule CODE for " + profId); |
171 | 179 |
} |
172 | 180 |
return res.get(0); |
... | ... | |
196 | 204 |
this.mappingPolicyProfileId = mappingPolicyProfileId; |
197 | 205 |
} |
198 | 206 |
|
199 |
public String getMappingProfileId() { |
|
200 |
return mappingProfileId; |
|
207 |
public String getMappingProfileIds() {
|
|
208 |
return mappingProfileIds;
|
|
201 | 209 |
} |
202 | 210 |
|
203 |
public void setMappingProfileId(final String mappingProfileId) {
|
|
204 |
this.mappingProfileId = mappingProfileId;
|
|
211 |
public void setMappingProfileIds(final String mappingProfileIds) {
|
|
212 |
this.mappingProfileIds = mappingProfileIds;
|
|
205 | 213 |
} |
206 | 214 |
|
207 | 215 |
public boolean isVerboseLogging() { |
Also available in: Unified diff
X3M Transformation node must be able to handle multiple 3M mappings