47 lines
1.2 KiB
Java
47 lines
1.2 KiB
Java
package org.gcube.data.publishing.ckan2zenodo;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
|
|
import javax.xml.parsers.DocumentBuilder;
|
|
import javax.xml.parsers.DocumentBuilderFactory;
|
|
import javax.xml.parsers.ParserConfigurationException;
|
|
|
|
import org.gcube.common.resources.gcore.GenericResource;
|
|
import org.gcube.data.publishing.ckan2zenodo.commons.IS;
|
|
import org.gcube.data.publishing.ckan2zenodo.model.Mapping;
|
|
import org.gcube.data.publishing.ckan2zenodo.model.Mapping.Regexp;
|
|
import org.w3c.dom.Element;
|
|
import org.w3c.dom.NodeList;
|
|
|
|
import lombok.Synchronized;
|
|
|
|
|
|
public class TransformerManager {
|
|
|
|
|
|
|
|
private static DocumentBuilder builder=null;
|
|
|
|
@Synchronized
|
|
private static DocumentBuilder getBuilder() throws ParserConfigurationException {
|
|
if(builder==null) {
|
|
DocumentBuilderFactory factory =DocumentBuilderFactory.newInstance();
|
|
builder = factory.newDocumentBuilder();
|
|
}
|
|
return builder;
|
|
}
|
|
|
|
public Transformer getByProfile(String profile) throws Exception {
|
|
for(GenericResource r: IS.queryForGenericResources("Ckan-Zenodo-Mappings")){
|
|
if (r.profile().name().equals(profile))
|
|
return new Transformer(IS.readMappings(r));
|
|
}
|
|
throw new Exception("No transformer found for profile "+profile);
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|