improving code
This commit is contained in:
parent
579cc27183
commit
f30f35ec49
|
@ -7,6 +7,7 @@ import java.util.Calendar;
|
|||
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.gcube.com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import org.gcube.com.fasterxml.jackson.databind.node.JsonNodeType;
|
||||
import org.gcube.com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import org.gcube.common.software.utils.Utils;
|
||||
|
||||
|
@ -15,6 +16,7 @@ import org.gcube.common.software.utils.Utils;
|
|||
*/
|
||||
public class AnalyserFactory {
|
||||
|
||||
public static final String EXPORT_FILENAME_PROPERTY_NAME = "export_filename";
|
||||
public static final String EXPORT_FILENAME_EXTENSION = ".json";
|
||||
|
||||
public static final String GLOBAL_PROPERTY_NAME = "global";
|
||||
|
@ -58,9 +60,10 @@ public class AnalyserFactory {
|
|||
return fileName;
|
||||
}
|
||||
|
||||
|
||||
public static void writeAnalysResultToFile(Analyser analyser) throws Exception {
|
||||
String fileName = getExportFileName(null);
|
||||
JsonNode jsonNode = analyser.getOriginalGlobal().get(AnalyserFactory.EXPORT_FILENAME_PROPERTY_NAME);
|
||||
String fileName = jsonNode.getNodeType() == JsonNodeType.NULL ? null : jsonNode.asText();
|
||||
fileName = AnalyserFactory.getExportFileName(fileName);
|
||||
File file = new File(fileName);
|
||||
writeAnalysResultToFile(analyser, file);
|
||||
}
|
||||
|
|
|
@ -82,10 +82,10 @@ public class SoftwareVersionConfigAnalyser {
|
|||
logger.debug("Goign to export with {}", className);
|
||||
Class<? extends SoftwareVersionExporter> exporterClass = availableExporters.get(className);
|
||||
SoftwareVersionExporter sve = exporterClass.newInstance();
|
||||
ExporterConfig processorConfig = requestedExporters.get(className);
|
||||
ExporterConfig exporterConfig = requestedExporters.get(className);
|
||||
sve.setGlobalConfig(softwareConfig);
|
||||
sve.setSoftwareVersion(softwareVersionConfig);
|
||||
sve.setExporterConfig(processorConfig);
|
||||
sve.setExporterConfig(exporterConfig);
|
||||
sve.setFirst(first);
|
||||
sve.export();
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import java.util.Set;
|
|||
|
||||
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.gcube.com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import org.gcube.com.fasterxml.jackson.databind.node.JsonNodeType;
|
||||
import org.gcube.common.software.analyser.AnalyserFactory;
|
||||
import org.gcube.common.software.export.SoftwareVersionExporter;
|
||||
import org.gcube.common.software.model.ElaborationType;
|
||||
|
@ -184,7 +185,9 @@ public class BibLaTeXSoftwareVersionExporter extends SoftwareVersionExporter {
|
|||
}
|
||||
|
||||
protected File getExportFile() {
|
||||
String fileName = AnalyserFactory.getExportFileName(null);
|
||||
JsonNode jsonNode = globalConfig.getProperty(AnalyserFactory.EXPORT_FILENAME_PROPERTY_NAME);
|
||||
String fileName = jsonNode.getNodeType() == JsonNodeType.NULL ? null : jsonNode.asText();
|
||||
fileName = AnalyserFactory.getExportFileName(fileName);
|
||||
File file = new File(fileName + EXPORT_FILENAME_EXTENSION);
|
||||
return file;
|
||||
}
|
||||
|
|
|
@ -117,6 +117,17 @@ public class Variables {
|
|||
}
|
||||
return missingVariables;
|
||||
}
|
||||
|
||||
public Set<String> parseWith(Variables variables) throws Exception {
|
||||
for(String property : properties.keySet()) {
|
||||
variables.addProperty(property, properties.get(property));
|
||||
}
|
||||
Set<String> missingVariables = variables.parse();
|
||||
for(String property : properties.keySet()) {
|
||||
properties.put(property, variables.getProperties().get(property));
|
||||
}
|
||||
return missingVariables;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public Map<String, Object> getProperties() {
|
||||
|
|
Loading…
Reference in New Issue