Skip to content
Snippets Groups Projects
Commit 83510919 authored by gakin's avatar gakin
Browse files

SSDM-4559 Add further master data attributes to MasterDataParser

SVN: 37579
parent 42dba549
No related branches found
No related tags found
No related merge requests found
...@@ -35,6 +35,7 @@ import ch.systemsx.cisd.openbis.generic.server.jython.api.v1.IPropertyAssignment ...@@ -35,6 +35,7 @@ import ch.systemsx.cisd.openbis.generic.server.jython.api.v1.IPropertyAssignment
import ch.systemsx.cisd.openbis.generic.server.jython.api.v1.IPropertyType; import ch.systemsx.cisd.openbis.generic.server.jython.api.v1.IPropertyType;
import ch.systemsx.cisd.openbis.generic.server.jython.api.v1.ISampleType; import ch.systemsx.cisd.openbis.generic.server.jython.api.v1.ISampleType;
import ch.systemsx.cisd.openbis.generic.server.jython.api.v1.IVocabulary; import ch.systemsx.cisd.openbis.generic.server.jython.api.v1.IVocabulary;
import ch.systemsx.cisd.openbis.generic.server.jython.api.v1.IVocabularyTerm;
/** /**
* *
...@@ -82,11 +83,16 @@ public class MasterDataParser ...@@ -82,11 +83,16 @@ public class MasterDataParser
for (int i = 0; i < vocabNodes.getLength(); i++) for (int i = 0; i < vocabNodes.getLength(); i++)
{ {
Element vocabElement = (Element) vocabNodes.item(i); Element vocabElement = (Element) vocabNodes.item(i);
String code = vocabElement.getAttributes().getNamedItem("code").getTextContent(); String code = getAttribute(vocabElement, "code");
if (code.startsWith("$")) if (code.startsWith("$"))
continue; continue;
//TODO complete other attributes //TODO complete other attributes
IVocabulary newVocabulary = masterDataRegistrationTransaction.getOrCreateNewVocabulary(code); IVocabulary newVocabulary = masterDataRegistrationTransaction.getOrCreateNewVocabulary(code);
newVocabulary.setDescription(getAttribute(vocabElement, "description"));
newVocabulary.setUrlTemplate(getAttribute(vocabElement, "urlTemplate"));
newVocabulary.setInternalNamespace(Boolean.valueOf(getAttribute(vocabElement, "internalNamespace")));
newVocabulary.setManagedInternally(Boolean.valueOf(getAttribute(vocabElement, "managedInternally")));
newVocabulary.setChosenFromList(Boolean.valueOf(getAttribute(vocabElement, "chosenFromList")));
vocabularyMap.put(code, newVocabulary); vocabularyMap.put(code, newVocabulary);
parseVocabularyTerms(vocabElement, newVocabulary); parseVocabularyTerms(vocabElement, newVocabulary);
} }
...@@ -99,12 +105,21 @@ public class MasterDataParser ...@@ -99,12 +105,21 @@ public class MasterDataParser
for (int i = 0; i < termNodes.getLength(); i++) for (int i = 0; i < termNodes.getLength(); i++)
{ {
Element termElement = (Element) termNodes.item(i); Element termElement = (Element) termNodes.item(i);
// TODO set other attributes String code = getAttribute(termElement, "code");
String code = termElement.getAttributes().getNamedItem("code").getTextContent(); IVocabularyTerm newVocabularyTerm = masterDataRegistrationTransaction.createNewVocabularyTerm(code);
newVocabulary.addTerm(masterDataRegistrationTransaction.createNewVocabularyTerm(code)); newVocabularyTerm.setLabel(getAttribute(termElement, "label"));
newVocabularyTerm.setDescription(getAttribute(termElement, "description"));
newVocabularyTerm.setOrdinal(Long.valueOf(getAttribute(termElement, "ordinal")));
// TODO setUrl?
newVocabulary.addTerm(newVocabularyTerm);
} }
} }
private String getAttribute(Element termElement, String attr)
{
return termElement.getAttributes().getNamedItem(attr).getTextContent();
}
private void parseSampleTypes(NodeList sampleTypesNode) private void parseSampleTypes(NodeList sampleTypesNode)
{ {
if (sampleTypesNode.getLength() == 1) if (sampleTypesNode.getLength() == 1)
...@@ -114,7 +129,7 @@ public class MasterDataParser ...@@ -114,7 +129,7 @@ public class MasterDataParser
for (int i = 0; i < sampleTypeNodes.getLength(); i++) for (int i = 0; i < sampleTypeNodes.getLength(); i++)
{ {
Element sampleTypeElement = (Element) sampleTypeNodes.item(i); Element sampleTypeElement = (Element) sampleTypeNodes.item(i);
String code = sampleTypeElement.getAttributes().getNamedItem("code").getTextContent(); String code = getAttribute(sampleTypeElement, "code");
ISampleType newSampleType = masterDataRegistrationTransaction.getOrCreateNewSampleType(code); ISampleType newSampleType = masterDataRegistrationTransaction.getOrCreateNewSampleType(code);
newSampleType.setGeneratedCodePrefix("S"); newSampleType.setGeneratedCodePrefix("S");
...@@ -133,18 +148,20 @@ public class MasterDataParser ...@@ -133,18 +148,20 @@ public class MasterDataParser
{ {
Element propertyAssignmentElement = (Element) propertyAssignmentNodes.item(i); Element propertyAssignmentElement = (Element) propertyAssignmentNodes.item(i);
// TODO set other attributes // TODO set other attributes
String property_type_code = propertyAssignmentElement.getAttributes().getNamedItem("property_type_code").getTextContent(); String property_type_code = getAttribute(propertyAssignmentElement, "property_type_code");
String data_type_code = propertyAssignmentElement.getAttributes().getNamedItem("data_type_code").getTextContent(); String data_type_code = getAttribute(propertyAssignmentElement, "data_type_code");
if (property_type_code.startsWith("$")) if (property_type_code.startsWith("$"))
continue; continue;
boolean mandatory = Boolean.valueOf(propertyAssignmentElement.getAttributes().getNamedItem("mandatory").getTextContent()); boolean mandatory = Boolean.valueOf(getAttribute(propertyAssignmentElement, "mandatory"));
int ordinal = Integer.valueOf(propertyAssignmentElement.getAttributes().getNamedItem("ordinal").getTextContent()); long ordinal = Long.valueOf(getAttribute(propertyAssignmentElement, "ordinal"));
String section = getAttribute(propertyAssignmentElement, "section");
if (propertyTypeMap.get(property_type_code) != null) if (propertyTypeMap.get(property_type_code) != null)
{ {
IPropertyAssignment assignment = IPropertyAssignment assignment =
masterDataRegistrationTransaction.assignPropertyType(newSampleType, propertyTypeMap.get(property_type_code)); masterDataRegistrationTransaction.assignPropertyType(newSampleType, propertyTypeMap.get(property_type_code));
assignment.setMandatory(mandatory); assignment.setMandatory(mandatory);
assignment.setSection(section);
} }
} }
} }
...@@ -159,15 +176,15 @@ public class MasterDataParser ...@@ -159,15 +176,15 @@ public class MasterDataParser
for (int i = 0; i < propertyTypeNodes.getLength(); i++) for (int i = 0; i < propertyTypeNodes.getLength(); i++)
{ {
Element propertyTypeElement = (Element) propertyTypeNodes.item(i); Element propertyTypeElement = (Element) propertyTypeNodes.item(i);
String code = propertyTypeElement.getAttributes().getNamedItem("code").getTextContent(); String code = getAttribute(propertyTypeElement, "code");
// TODO handle internal properties // TODO handle internal properties
if (code.startsWith("$")) if (code.startsWith("$"))
continue; continue;
String label = propertyTypeElement.getAttributes().getNamedItem("label").getTextContent(); String label = getAttribute(propertyTypeElement, "label");
String dataType = propertyTypeElement.getAttributes().getNamedItem("dataType").getTextContent(); String dataType = getAttribute(propertyTypeElement, "dataType");
String description = propertyTypeElement.getAttributes().getNamedItem("description").getTextContent(); String description = getAttribute(propertyTypeElement, "description");
boolean internalNamespace = Boolean.valueOf(propertyTypeElement.getAttributes().getNamedItem("internalNamespace").getTextContent()); boolean internalNamespace = Boolean.valueOf(getAttribute(propertyTypeElement, "internalNamespace"));
boolean managedInternally = Boolean.valueOf(propertyTypeElement.getAttributes().getNamedItem("managedInternally").getTextContent()); boolean managedInternally = Boolean.valueOf(getAttribute(propertyTypeElement, "managedInternally"));
String vocabulary = null; String vocabulary = null;
Node namedItem = propertyTypeElement.getAttributes().getNamedItem("vocabulary"); Node namedItem = propertyTypeElement.getAttributes().getNamedItem("vocabulary");
if (namedItem != null) if (namedItem != null)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment