diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 714351a..b8947ec 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -2,4 +2,5 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.release=disabled org.eclipse.jdt.core.compiler.source=1.8 diff --git a/src/main/java/org/gcube/data/publishing/ckan2zenodo/Translator.java b/src/main/java/org/gcube/data/publishing/ckan2zenodo/Translator.java index 4fcdd02..b4d6cf1 100644 --- a/src/main/java/org/gcube/data/publishing/ckan2zenodo/Translator.java +++ b/src/main/java/org/gcube/data/publishing/ckan2zenodo/Translator.java @@ -230,11 +230,21 @@ public class Translator { if(targetElementFound==null || targetElementFound.size()==0 || targetElementFound.get(0)==null) { // targetCtx=targetCtx.add(mapping.getTargetPath(),Collections.singletonList("nothing")); targetCtx=Parsing.addElement(targetCtx, mapping.getTargetPath()); + } + + + if(mapping.getTargetElement().getAppend()){ + String original=((List)targetCtx.read(mapping.getTargetPath()+"."+mapping.getTargetElement().getTargetElement())).get(0); + if(original!=null && !original.isEmpty()) + resultingValue=original+resultingValue; } - - // apply resulting value - - targetCtx=targetCtx.put(mapping.getTargetPath(),mapping.getTargetElement(),resultingValue); + + + + + + targetCtx=targetCtx.put(mapping.getTargetPath(),mapping.getTargetElement().getTargetElement(), + resultingValue); } }catch(Throwable t) { throw new TransformationException("Exception while applying "+mapping,t); diff --git a/src/main/java/org/gcube/data/publishing/ckan2zenodo/commons/IS.java b/src/main/java/org/gcube/data/publishing/ckan2zenodo/commons/IS.java index 79e47f5..f2805c9 100644 --- a/src/main/java/org/gcube/data/publishing/ckan2zenodo/commons/IS.java +++ b/src/main/java/org/gcube/data/publishing/ckan2zenodo/commons/IS.java @@ -15,6 +15,7 @@ import org.gcube.data.publishing.ckan2zenodo.model.parsing.Mapping; import org.gcube.data.publishing.ckan2zenodo.model.parsing.Mapping.Regexp; import org.gcube.data.publishing.ckan2zenodo.model.parsing.Mapping.Source; import org.gcube.data.publishing.ckan2zenodo.model.parsing.Mapping.Source.Value; +import org.gcube.data.publishing.ckan2zenodo.model.parsing.Mapping.TargetElement; import org.gcube.data.publishing.ckan2zenodo.model.parsing.ResourceFilter; import org.gcube.resources.discovery.client.api.DiscoveryClient; import org.gcube.resources.discovery.client.queries.api.SimpleQuery; @@ -67,13 +68,23 @@ public class IS { Source source=new Source(); for(int j=0;j values=new HashMap<>(); NodeList valueMappings=mapping.getElementsByTagName("valueMapping"); @@ -100,7 +111,7 @@ public class IS { } - toReturn.add(new Mapping(source,targetPath,targetElement,values,regularExpressions)); + toReturn.add(new Mapping(source,targetPath,targetObject,values,regularExpressions)); } diff --git a/src/main/java/org/gcube/data/publishing/ckan2zenodo/model/parsing/Mapping.java b/src/main/java/org/gcube/data/publishing/ckan2zenodo/model/parsing/Mapping.java index aa84c30..775b013 100644 --- a/src/main/java/org/gcube/data/publishing/ckan2zenodo/model/parsing/Mapping.java +++ b/src/main/java/org/gcube/data/publishing/ckan2zenodo/model/parsing/Mapping.java @@ -41,7 +41,7 @@ public class Mapping { public static enum Type{ jsonPath,constant } - + @Setter private String split; @NonNull private Type type; @@ -52,13 +52,23 @@ public class Mapping { private List values=new ArrayList<>(); } + @Getter + @ToString + @RequiredArgsConstructor + public static class TargetElement{ + @Setter + private Boolean append = false; + @NonNull + private String targetElement; + } + @NonNull private Source source; @NonNull private String targetPath; @NonNull - private String targetElement; + private TargetElement targetElement; @NonNull private HashMap valueMapping; @NonNull diff --git a/src/test/resources/blue_cloud_dataset.xml b/src/test/resources/blue_cloud_dataset.xml index 26eb82d..c4140cd 100644 --- a/src/test/resources/blue_cloud_dataset.xml +++ b/src/test/resources/blue_cloud_dataset.xml @@ -58,7 +58,7 @@ $.extras[?(@.key=='Identity:Owner')].value - $.metadata.contributors[3] + $.metadata.contributors[*] name @@ -66,7 +66,7 @@ ContactPerson - $.metadata.contributors[3] + $.metadata.contributors[*] type @@ -146,14 +146,14 @@ $.extras[?(@.key=='AccessMode:Accessibility')].value $.metadata - access_conditions + access_conditions ^ AccessMode.Accessibility : $ - ; + ; @@ -163,8 +163,15 @@ $.extras[?(@.key=='AccessMode:Availability')].value $.metadata - access_conditions - + access_conditions + + ^ + AccessMode.Availability : + + + $ + ; + @@ -173,7 +180,15 @@ $.extras[?(@.key=='AccessMode:AccessibilityMode')].value $.metadata - access_conditions + access_conditions + + ^ + AccessMode.AccessibilityMode : + + + $ + ; + @@ -183,7 +198,15 @@ $.extras[?(@.key=='TechnicalDetails:ProcessingDegree')].value $.metadata - notes + notes + + ^ + TechnicalDetails.ProcessingDegree : + + + $ + ; + @@ -192,7 +215,15 @@ $.extras[?(@.key=='TechnicalDetails:ManifestationType')].value $.metadata - notes + notes + + ^ + TechnicalDetails.ManifestationType : + + + $ + ; + @@ -210,7 +241,15 @@ $.extras[?(@.key=='TechnicalDetails:Size')].value $.metadata - notes + notes + + ^ + TechnicalDetails.Size : + + + $ + ; + @@ -219,7 +258,15 @@ $.extras[?(@.key=='TechnicalDetails:DiskSize')].value $.metadata - notes + notes + + ^ + TechnicalDetails.DiskSize : + + + $ + ; + @@ -228,7 +275,15 @@ $.extras[?(@.key=='TechnicalDetails:Format')].value $.metadata - notes + notes + + ^ + TechnicalDetails.Format : + + + $ + ; + @@ -237,7 +292,15 @@ $.extras[?(@.key=='TechnicalDetails:FormatSchema')].value $.metadata - notes + notes + + ^ + TechnicalDetails.FormatSchema : + + + $ + ; + @@ -247,7 +310,15 @@ $.extras[?(@.key=='DataProtection:PersonalData')].value $.metadata - notes + notes + + ^ + DataProtection.PersonalData : + + + $ + ; + @@ -256,7 +327,15 @@ $.extras[?(@.key=='DataProtection:PersonalSensitiveData')].value $.metadata - notes + notes + + ^ + DataProtection.PersonalSensitiveData : + + + $ + ; + @@ -266,7 +345,15 @@ $.extras[?(@.key=='DataProtection:Consent of the data subject')].value $.metadata - notes + notes + + ^ + DataProtection.Consent of the data subject : + + + $ + ; + @@ -275,7 +362,15 @@ $.extras[?(@.key=='DataProtection:Consent obtained also covers the envisaged transfer of the personal data outside the EU')].value $.metadata - notes + notes + + ^ + DataProtection.Consent obtained also covers the envisaged transfer of the personal data outside the EU : + + + $ + ; + @@ -284,7 +379,15 @@ $.extras[?(@.key=='DataProtection:Personal data was manifestly made public by the data subject')].value $.metadata - notes + notes + + ^ + DataProtection.Personal data was manifestly made public by the data subject : + + + $ + ; + @@ -293,7 +396,15 @@ $.extras[?(@.key=='DataProtection:PersonalSensitiveData')].value $.metadata - notes + notes + + ^ + DataProtection.DataProtectionDirective : + + + $ + ; + @@ -303,7 +414,15 @@ $.extras[?(@.key=='Rights:IP/Copyrights')].value $.metadata - notes + notes + + ^ + Rights.IP/Copyrights : + + + $ + ; + @@ -312,7 +431,15 @@ $.extras[?(@.key=='Rights:Field/Scope of use')].value $.metadata - notes + notes + + ^ + Rights.Field/Scope of use : + + + $ + ; + @@ -322,7 +449,15 @@ $.extras[?(@.key=='Rights:Basic rights')].value $.metadata - notes + notes + + ^ + Rights.Basic rights : + + + $ + ; + @@ -332,7 +467,15 @@ $.extras[?(@.key=='Rights:Restrictions on use')].value $.metadata - notes + notes + + ^ + Rights.Restrictions on use : + + + $ + ; + @@ -342,7 +485,15 @@ $.extras[?(@.key=='Rights:Sublicense rights')].value $.metadata - notes + notes + + ^ + Rights.Sublicense rights : + + + $ + ; + @@ -351,7 +502,15 @@ $.extras[?(@.key=='Rights:Territory of use')].value $.metadata - notes + notes + + ^ + Rights.Territory of use : + + + $ + ; + @@ -360,7 +519,15 @@ $.extras[?(@.key=='Rights:License term')].value $.metadata - notes + notes + + ^ + Rights.License term : + + + $ + ; + @@ -370,7 +537,15 @@ $.extras[?(@.key=='Rights:Requirement of non-disclosure (confidentiality mark)')].value $.metadata - notes + notes + + ^ + Rights.Requirement of non-disclosure (confidentiality mark) : + + + $ + ; + @@ -380,7 +555,15 @@ $.extras[?(@.key=='Attribution:Attribution requirements')].value $.metadata - notes + notes + + ^ + Attribution.Attribution requirements : + + + $ + ; + @@ -390,7 +573,15 @@ $.extras[?(@.key=='Attribution:Attribution requirements')].value $.metadata - notes + notes + + ^ + Attribution.Display requirements : + + + $ + ; + @@ -400,7 +591,15 @@ $.extras[?(@.key=='Attribution:Distribution requirements')].value $.metadata - notes + notes + + ^ + Attribution.Distribution requirements : + + + $ + ; +