org.hisrc.jsonix.configuration.ModuleConfiguration Maven / Gradle / Ivy
package org.hisrc.jsonix.configuration;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import javax.xml.namespace.QName;
import org.hisrc.jsonix.analysis.ModelInfoGraphAnalyzer;
import org.hisrc.jsonix.definition.Mapping;
import org.hisrc.jsonix.definition.Module;
import org.hisrc.jsonix.definition.Output;
import org.jvnet.jaxb2_commons.xml.bind.model.MModelInfo;
@XmlRootElement(name = ModuleConfiguration.LOCAL_ELEMENT_NAME)
@XmlType(propOrder = {})
public class ModuleConfiguration {
public static final String LOCAL_ELEMENT_NAME = "module";
// private Log log = new SystemLog();
public static final String MODULE_NAME_PROPERTY = "${module.name}";
public static final String MODULE_NAME_SEPARATOR = "_";
private String name;
private List mappingConfigurations = new LinkedList();
private List outputConfigurations = new LinkedList();
public static final QName MODULE_NAME = new QName(
ModulesConfiguration.NAMESPACE_URI, LOCAL_ELEMENT_NAME,
ModulesConfiguration.DEFAULT_PREFIX);
@XmlAttribute(name = "name")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@XmlElement(name = "mapping")
public List getMappingConfigurations() {
return mappingConfigurations;
}
public void setMappingConfigurations(
List mappingConfigurations) {
this.mappingConfigurations = mappingConfigurations;
}
@XmlElement(name = "output")
public List getOutputConfigurations() {
return outputConfigurations;
}
public void setOutputConfigurations(
List outputConfigurations) {
this.outputConfigurations = outputConfigurations;
}
public Module build(
ModelInfoGraphAnalyzer analyzer, MModelInfo modelInfo,
Map> mappings) {
// final Logger logger =
// Validate.notNull(context).getLoggerFactory().getLogger(
// ModuleConfiguration.class.getName());
final List mappingConfigurations = getMappingConfigurations();
final List> moduleMappings = new ArrayList>(
mappingConfigurations.size());
for (MappingConfiguration mappingConfiguration : mappingConfigurations) {
Mapping moduleMapping = mappings.get(mappingConfiguration
.getId());
if (moduleMapping != null) {
moduleMappings.add(moduleMapping);
}
}
if (moduleMappings.isEmpty()) {
return null;
}
final String moduleName;
if (this.name != null) {
moduleName = this.name;
} else {
moduleName = createModuleName(moduleMappings);
}
final List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy