86 lines
4.1 KiB
Java
86 lines
4.1 KiB
Java
package eu.eudat.logic.managers;
|
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import javax.management.InvalidApplicationException;
|
|
import javax.xml.xpath.XPathExpressionException;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
|
|
@Component
|
|
public class DatasetProfileManager {
|
|
private static final Logger logger = LoggerFactory.getLogger(DatasetProfileManager.class);
|
|
private static final List<String> cache = new ArrayList<>();
|
|
|
|
// private final RemoteFetcherService remoteFetcherService;
|
|
|
|
@Autowired
|
|
public DatasetProfileManager() {
|
|
|
|
}
|
|
private static String parseItem(Object item) {
|
|
if (item instanceof String) {
|
|
return (String) item;
|
|
}
|
|
if (item instanceof List) {
|
|
List listedItems = (List) item;
|
|
return parseItem(listedItems.get(0));
|
|
}
|
|
if (item instanceof Map) {
|
|
return String.valueOf(((Map)item).get("$"));
|
|
}
|
|
return item != null ? item.toString() : null;
|
|
}
|
|
|
|
public void addSemanticsInDatasetProfiles() throws XPathExpressionException, InvalidApplicationException {
|
|
// List<DescriptionTemplateEntity> ids = this.databaseRepository.getDatasetProfileDao().getAllIds();
|
|
// for(DescriptionTemplateEntity dp: ids){
|
|
// DescriptionTemplateEntity descriptionTemplateEntity = this.databaseRepository.getDatasetProfileDao().find(dp.getId());
|
|
// Document document = XmlBuilder.fromXml(descriptionTemplateEntity.getDefinition());
|
|
// XPathFactory xpathFactory = XPathFactory.newInstance();
|
|
// XPath xpath = xpathFactory.newXPath();
|
|
// XPathExpression expr = xpath.compile("//rdaCommonStandard");
|
|
// NodeList rdaProperties = (NodeList) expr.evaluate(document, XPathConstants.NODESET);
|
|
// for(int i = 0; i < rdaProperties.getLength(); i++){
|
|
// Node rdaPropertyNode = rdaProperties.item(i);
|
|
// String rdaProperty = rdaPropertyNode.getTextContent();
|
|
// Element schematics = document.createElement("schematics");
|
|
// Node fieldParent = rdaPropertyNode.getParentNode();
|
|
// if(rdaProperty != null && !rdaProperty.isEmpty()){
|
|
// Element schematic = document.createElement("schematic");
|
|
// schematic.setTextContent("rda." + rdaProperty);
|
|
// schematics.appendChild(schematic);
|
|
// }
|
|
// fieldParent.insertBefore(schematics, rdaPropertyNode);
|
|
// fieldParent.removeChild(rdaPropertyNode);
|
|
// }
|
|
// this.updateDatasetProfileXml(document, descriptionTemplateEntity);
|
|
// }
|
|
}
|
|
|
|
public void addRdaInSemanticsInDatasetProfiles() throws XPathExpressionException, InvalidApplicationException {
|
|
// List<DescriptionTemplateEntity> ids = this.databaseRepository.getDatasetProfileDao().getAllIds();
|
|
// for(DescriptionTemplateEntity dp: ids){
|
|
// DescriptionTemplateEntity descriptionTemplateEntity = this.databaseRepository.getDatasetProfileDao().find(dp.getId());
|
|
// Document document = XmlBuilder.fromXml(descriptionTemplateEntity.getDefinition());
|
|
// XPathFactory xpathFactory = XPathFactory.newInstance();
|
|
// XPath xpath = xpathFactory.newXPath();
|
|
// XPathExpression expr = xpath.compile("//schematic");
|
|
// NodeList schematics = (NodeList) expr.evaluate(document, XPathConstants.NODESET);
|
|
// for (int i = 0; i < schematics.getLength(); i++) {
|
|
// Node schematicNode = schematics.item(i);
|
|
// String schematicRda = schematicNode.getTextContent();
|
|
// if (schematicRda != null && !schematicRda.isEmpty() && !schematicRda.startsWith("rda.")) {
|
|
// schematicNode.setTextContent("rda." + schematicRda);
|
|
// }
|
|
// }
|
|
// this.updateDatasetProfileXml(document, descriptionTemplateEntity);
|
|
// }
|
|
}
|
|
}
|