import java.io.FileNotFoundException;
import java.io.IOException;
import java.sql.SQLException;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
import java.util.Set;
-import java.util.Vector;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
/**
* The logger for the service.
*/
- protected final static Logger logger = Logger
+ protected final static Logger LOG = Logger
.getLogger(ProjectSettingsServiceImpl.class);
// Non persistent configuration information
/**
* Repository settings.
*/
- private final Properties reprop = new Properties();
+ private transient final Properties _reprop = new Properties();
/**
* Pattern of study references.
*/
- private String pattern;
+ private transient String _pattern;
/**
* Scheme of file names stored into the repository.
*/
- private FileNaming naming;
+ private transient FileNaming _naming;
/**
* Pattern of the presentation of version numbers.
*/
- private String versioning;
+ private transient String _versioning;
/**
* Ordered list of (transient) study steps.
*/
- private final Vector<ProjectSettingsService.Step> steps = new Vector<ProjectSettingsService.Step>();
+ private transient final List<ProjectSettingsService.Step> _steps = new ArrayList<ProjectSettingsService.Step>();
/**
* Configuration document validation cycles.
*/
- private Vector<ProjectSettingsValidationCycle> concycles;
+ private transient List<ProjectSettingsValidationCycle> _concycles;
// Temporary attributes initialized from the configuration file for populating the database with object types
/**
* Document type names and uses mapping.
*/
- private LinkedHashMap<String, String> mapuse;
+ private transient Map<String, String> _mapuse;
/**
* Simulation Context type names.
*/
- private Vector<String> context;
+ private transient List<String> _context;
/**
* Knowledge Element type names.
*/
- private Vector<String> kname;
+ private transient List<String> _kname;
/**
* Document flows.
*/
- private Vector<NamedNodeMap> flows;
+ private transient List<NamedNodeMap> _flows;
/**
* Study classifications.
*/
- private Vector<NamedNodeMap> sclass;
+ private transient List<NamedNodeMap> _sclass;
// Other resources
/**
/**
* Cycle (document) type name.
*/
- private final String name;
+ private final String _name;
/**
* Array of cycle actors positions in the organization. TODO: Must be replaced by Roles.
*/
- private final Actor[] actor;
+ private final Actor[] _actor;
/**
* Default constructor.
*/
private ProjectSettingsValidationCycle() {
- this.name = "built-in";
- this.actor = new Actor[] { null, null, null };
+ this._name = "built-in";
+ this._actor = new Actor[] { null, null, null };
}
/**
*/
private ProjectSettingsValidationCycle(final String name,
final Actor[] actor) {
- this.name = name;
- this.actor = actor;
+ this._name = name;
+ this._actor = actor;
}
/**
* @return the document type name
*/
public String getName() {
- return name;
+ return _name;
}
/**
* @see org.splat.dal.bo.som.ValidationCycle.Actor
*/
public Actor[] getActorTypes() {
- return actor;
+ return _actor;
}
}
*/
public void configure(final String filename) throws IOException,
SQLException {
- if (!steps.isEmpty()) {
+ if (!_steps.isEmpty()) {
return; // Project already configured
}
if (config.exists()) {
loadCustomization(config);
} else {
- logger.fatal("Could not find the database configuration file \""
+ LOG.fatal("Could not find the database configuration file \""
+ config.getAbsolutePath() + "\"");
throw new FileNotFoundException();
}
- base.configure(reprop);
+ base.configure(_reprop);
if (!base.isInitialized()) {
base.initialize();
initialize(); // Populates the database with all necessary stuff
* @return the list of steps from project settings
*/
public List<ProjectSettingsService.Step> getAllSteps() {
- return steps;
+ return _steps;
}
/**
* @return the validation cycles of the workflow
*/
public List<ProjectSettingsValidationCycle> getAllValidationCycles() {
- return concycles;
+ return _concycles;
}
/**
* @see org.splat.service.technical.ProjectSettingsServiceImpl.FileNaming
*/
public FileNaming getFileNamingScheme() {
- return naming;
+ return _naming;
}
/**
* @return the reference pattern
*/
public String getReferencePattern() {
- return pattern;
+ return _pattern;
}
/**
* @return the version numbers presentation pattern
*/
public String getRevisionPattern() {
- return versioning;
+ return _versioning;
}
/**
* @return the step
*/
public ProjectSettingsService.Step getStep(final int number) {
- for (int i = 0; i < steps.size(); i++) {
- ProjectSettingsService.Step step = steps.get(i);
- if (step.number == number) {
- return step;
+ ProjectSettingsService.Step res = null;
+ for (int i = 0; i < _steps.size(); i++) {
+ ProjectSettingsService.Step step = _steps.get(i);
+ if (step.getNumber() == number) {
+ res = step;
+ break;
}
}
- return null;
+ return res;
}
/**
*/
public List<ProjectSettingsService.Step> getStepsOf(
final Class<? extends ProjectElement> level) {
- Vector<ProjectSettingsService.Step> result = new Vector<ProjectSettingsService.Step>();
+ List<ProjectSettingsService.Step> result = new ArrayList<ProjectSettingsService.Step>();
- for (int i = 0; i < steps.size(); i++) {
- ProjectSettingsService.Step step = steps.get(i);
+ for (int i = 0; i < _steps.size(); i++) {
+ ProjectSettingsService.Step step = _steps.get(i);
if (step.appliesTo(level)) {
result.add(step);
}
if (!disk.endsWith("/")) {
disk = disk + "/";
}
- logger.info("Database root set to " + disk);
- reprop.setProperty("repository", disk);
+ LOG.info("Database root set to " + disk);
+ _reprop.setProperty("repository", disk);
// Formats tag initializing the reference pattern and date attributes
child = children.get("formats");
datag = XDOM.getNamedChildNodes(child);
NamedNodeMap natr = datag.get("references").getAttributes();
- pattern = natr.getNamedItem("study").getNodeValue();
+ _pattern = natr.getNamedItem("study").getNodeValue();
natr = datag.get("files").getAttributes();
- naming = FileNaming.valueOf(natr.getNamedItem("name")
+ _naming = FileNaming.valueOf(natr.getNamedItem("name")
.getNodeValue());
natr = datag.get("versions").getAttributes();
- versioning = natr.getNamedItem("pattern").getNodeValue();
+ _versioning = natr.getNamedItem("pattern").getNodeValue();
// Activities tag initializing the steps and rex attributes
child = children.get("activities");
NodeList nlist = child.getChildNodes();
- Vector<NamedNodeMap> flist = new Vector<NamedNodeMap>();
- Vector<String> resultype = new Vector<String>();
- Vector<NamedNodeMap> clist = new Vector<NamedNodeMap>();
+ List<NamedNodeMap> flist = new ArrayList<NamedNodeMap>();
+ List<String> resultype = new ArrayList<String>();
+ List<NamedNodeMap> clist = new ArrayList<NamedNodeMap>();
int snum = 1; // Base number of steps
for (int i = 0; i < nlist.getLength(); i++) {
}
child = tags.get("classification");
- if (child != null) {
- clist.add(child.getAttributes());
- } else {
+ if (child == null) {
clist.add(null);
+ } else {
+ clist.add(child.getAttributes());
}
if (natr.getNamedItem("contents").getNodeValue()
.equals("knowledge")) {
// TODO In a given scenario, only one step must contain knowledges
- step.contents.add(KnowledgeElement.class);
+ step._contents.add(KnowledgeElement.class);
} else {
- step.contents.add(Document.class);
+ step._contents.add(Document.class);
}
- steps.add(step);
+ _steps.add(step);
snum += 1;
}
} else {
}
child = tags.get("classification"); // Optional information
- if (child != null) {
- clist.add(child.getAttributes());
- } else {
+ if (child == null) {
clist.add(null);
+ } else {
+ clist.add(child.getAttributes());
}
if (natr.getNamedItem("contents").getNodeValue().equals(
"knowledge")) {
// TODO Error: knowledges must be attached to scenarios
+ LOG.error("Error: knowledges must be attached to scenarios.");
} else {
- step.contents.add(Document.class);
+ step._contents.add(Document.class);
}
- steps.add(step);
+ _steps.add(step);
snum += 1;
}
}
// Validations tag
child = children.get("validations");
- concycles = new Vector<ProjectSettingsValidationCycle>();
+ _concycles = new ArrayList<ProjectSettingsValidationCycle>();
datag = XDOM.getNamedChildNodes(child);
String[] step = { "review", "approval", "acceptance" };
}
actor[j] = Actor.valueOf(child.getNodeValue());
}
- concycles.add(new ProjectSettingsValidationCycle(name, actor));
+ _concycles.add(new ProjectSettingsValidationCycle(name, actor));
}
- concycles.add(new ProjectSettingsValidationCycle()); // Adds the built-in validation cycle
+ _concycles.add(new ProjectSettingsValidationCycle()); // Adds the built-in validation cycle
if (getDatabase().getCheckedDB().isInitialized()) {
return; // No need to load object type definitions as they are already stored
child = children.get("documents");
nlist = child.getChildNodes();
- flows = flist; // Kept for later use in document type definition
- sclass = clist; // Kept for later use in simulation context type definition
- mapuse = new LinkedHashMap<String, String>();
+ _flows = flist; // Kept for later use in document type definition
+ _sclass = clist; // Kept for later use in simulation context type definition
+ _mapuse = new LinkedHashMap<String, String>();
for (int i = 0; i < nlist.getLength(); i++) {
child = nlist.item(i);
if (!child.getNodeName().equals("article")) {
if (child != null) {
uses = child.getNodeValue();
}
- mapuse.put(type, uses); // Must be added to the map even if no (null) uses
+ _mapuse.put(type, uses); // Must be added to the map even if no (null) uses
}
// Simulation Contexts tag
child = children.get("contexts");
nlist = child.getChildNodes();
- context = new Vector<String>();
+ _context = new ArrayList<String>();
for (int i = 0; i < nlist.getLength(); i++) {
child = nlist.item(i);
if (!child.getNodeName().equals("article")) {
continue;
}
- context.add(child.getAttributes().getNamedItem("type")
+ _context.add(child.getAttributes().getNamedItem("type")
.getNodeValue());
}
// Knowledge Elements tag
child = children.get("knowledges");
nlist = child.getChildNodes();
- kname = new Vector<String>();
+ _kname = new ArrayList<String>();
for (int i = 0; i < nlist.getLength(); i++) {
child = nlist.item(i);
if (!child.getNodeName().equals("article")) {
continue;
}
- kname.add(child.getAttributes().getNamedItem("type")
+ _kname.add(child.getAttributes().getNamedItem("type")
.getNodeValue());
}
} catch (Exception error) {
- logger.info("Error in customization", error);
+ LOG.info("Error in customization", error);
}
}
*/
private void createDocumentTypes() {
DocumentType.Properties tprop = new DocumentType.Properties();
- HashMap<String, Vector<ProjectSettingsService.Step>> mapsteps = new HashMap<String, Vector<ProjectSettingsService.Step>>();
- HashMap<String, ProjectSettingsService.Step> mapresult = new HashMap<String, ProjectSettingsService.Step>();
- HashMap<String, DocumentType> maptype = new HashMap<String, DocumentType>();
+ Map<String, List<ProjectSettingsService.Step>> mapsteps = new HashMap<String, List<ProjectSettingsService.Step>>();
+ Map<String, ProjectSettingsService.Step> mapresult = new HashMap<String, ProjectSettingsService.Step>();
+ Map<String, DocumentType> maptype = new HashMap<String, DocumentType>();
- Vector<ProjectSettingsService.Step> slist = null; // List of Steps to which each document type is valid
+ List<ProjectSettingsService.Step> slist = null; // List of Steps to which each document type is valid
int snum = 0; // Step number
String type = null;
String uses = null;
- for (Iterator<NamedNodeMap> i = flows.iterator(); i.hasNext(); snum++) {
+ for (Iterator<NamedNodeMap> i = _flows.iterator(); i.hasNext(); snum++) {
NamedNodeMap flow = i.next();
- ProjectSettingsService.Step step = steps.get(snum);
+ ProjectSettingsService.Step step = _steps.get(snum);
String[] contents = flow.getNamedItem("contents").getNodeValue()
.split(",");
for (int j = 0; j < contents.length; j++) {
type = contents[j];
- if (!mapuse.containsKey(type)) {
- logger.warn("Undefined \"" + type + "\" document type.");
+ if (!_mapuse.containsKey(type)) {
+ LOG.warn("Undefined \"" + type + "\" document type.");
continue;
}
slist = mapsteps.get(type);
if (slist == null) {
- slist = new Vector<ProjectSettingsService.Step>();
+ slist = new ArrayList<ProjectSettingsService.Step>();
}
slist.add(step);
mapsteps.put(type, slist);
}
try {
DocumentType tdoc = null;
- Set<String> tset = mapuse.keySet();
+ Set<String> tset = _mapuse.keySet();
ProjectSettingsService.Step step;
for (Iterator<String> i = tset.iterator(); i.hasNext();) {
type = i.next();
slist = mapsteps.get(type);
- uses = mapuse.get(type);
+ uses = _mapuse.get(type);
step = mapresult.get(type);
tprop.clear();
if (uses != null) {
tdoc = maptype.get(uses);
if (tdoc == null) {
- logger
+ LOG
.warn("Undefined \"" + uses
+ "\" document type.");
} else {
maptype.put(type, tdoc);
}
} catch (Exception error) {
- logger.warn("Error creating document types, reason:", error); // Should not happen
+ LOG.warn("Error creating document types, reason:", error); // Should not happen
}
}
KnowledgeElementType ktype = getKnowledgeElementTypeService()
.createType("usecase"); // Internal reserved knowledge element type
getKnowledgeElementTypeService().reserve(ktype);
- for (Iterator<String> i = kname.iterator(); i.hasNext();) {
+ for (Iterator<String> i = _kname.iterator(); i.hasNext();) {
String type = i.next();
ktype = getKnowledgeElementTypeService().createType(type); // Knowledge Elements Types defined in the configuration
getKnowledgeElementTypeService().approve(ktype);
}
} catch (Exception error) {
- logger.warn("Error creating knowledge types, reason:", error); // Should not happen
+ LOG.warn("Error creating knowledge types, reason:", error); // Should not happen
}
}
* Create in the database simulation contexts types defined in the custom configuration.
*/
private void createSimulationContextTypes() {
- HashMap<String, ProjectSettingsService.Step> mapstep = new HashMap<String, ProjectSettingsService.Step>();
+ Map<String, ProjectSettingsService.Step> mapstep = new HashMap<String, ProjectSettingsService.Step>();
int snum = 0;
- for (Iterator<NamedNodeMap> i = sclass.iterator(); i.hasNext(); snum++) {
+ for (Iterator<NamedNodeMap> i = _sclass.iterator(); i.hasNext(); snum++) {
NamedNodeMap clatr = i.next();
if (clatr == null) {
continue;
String[] clist = clatr.getNamedItem("context").getNodeValue()
.split(",");
for (int j = 0; j < clist.length; j++) {
- mapstep.put(clist[j], steps.get(snum));
+ mapstep.put(clist[j], _steps.get(snum));
}
}
try {
SimulationContextType tctex = null;
- for (Iterator<String> i = context.iterator(); i.hasNext();) {
+ for (Iterator<String> i = _context.iterator(); i.hasNext();) {
String type = i.next();
if (!mapstep.containsKey(type)) {
- logger
+ LOG
.warn("Could not find \""
+ type
+ "\" classification. Simulation Context type ignored.");
getSimulationContextTypeService().approve(tctex);
}
} catch (Exception error) {
- logger.warn("Error creating context types, reason:", error); // Should not happen
+ LOG.warn("Error creating context types, reason:", error); // Should not happen
}
}