Skip to content

Commit

Permalink
added changes to ui to show context of value domain - data element - …
Browse files Browse the repository at this point in the history
…model relationship.

added changes to importer to create metadata on relationships between value domain - data element - model.
  • Loading branch information
amilward committed Jul 3, 2014
1 parent ba58884 commit 4ee80b4
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,24 @@ angular.module('mc.core.ui.bs.catalogueElementProperties', []).config ['catalogu
{header: 'Identification', value: "relation.elementTypeName + ': ' + relation.id", classes: 'col-md-5', show: "relation.show()"}
]

nameAndIdAndMetadata = -> [
{header: 'Name', value: "relation.name", classes: 'col-md-4', show: "relation.show()"}
{header: 'Identification', value: "relation.modelCatalogueId", classes: 'col-md-4', show: "relation.show()"}
{header: 'Metadata', value: printMetadata, classes: 'col-md-4'}
]

dataTypes = -> [
{header: 'Name', value: "relation.dataType.name", classes: 'col-md-6', show: "relation.dataType.show()"}
{header: 'Identification', value: "relation.dataType.elementTypeName + ': ' + relation.id", classes: 'col-md-5', show: "relation.dataType.show()"}
]

printMetadata = (relationship) ->
result = ''
ext = relationship.ext ? {}
for key, value of ext
result += "#{key}: #{value ? ''}\n"
result

computeBytes = (relationship) ->
asset = relationship.relation
GIGA = 1024 * 1024 * 1024
Expand All @@ -34,15 +47,15 @@ angular.module('mc.core.ui.bs.catalogueElementProperties', []).config ['catalogu
catalogueElementPropertiesProvider.configureProperty 'parentOf', label: 'Children', columns: nameAndIdent()
catalogueElementPropertiesProvider.configureProperty 'childOf', label: 'Parent', columns: nameAndIdent()
catalogueElementPropertiesProvider.configureProperty 'isContextFor', label: 'Models', columns: nameAndIdent()
catalogueElementPropertiesProvider.configureProperty 'includes', label: 'Value Domain', columns: nameAndIdent()
catalogueElementPropertiesProvider.configureProperty 'instantiatedBy', label: 'Value Domains', columns: nameAndIdent()
catalogueElementPropertiesProvider.configureProperty 'contains', label: 'Data Elements', columns: nameAndIdent()
catalogueElementPropertiesProvider.configureProperty 'containedIn', label: 'Models', columns: nameAndIdent()
catalogueElementPropertiesProvider.configureProperty 'includes', label: 'Value Domains', columns: nameAndIdent()
catalogueElementPropertiesProvider.configureProperty 'instantiatedBy', label: 'Value Domains', columns: nameAndIdAndMetadata()
catalogueElementPropertiesProvider.configureProperty 'contains', label: 'Data Elements', columns: nameAndIdAndMetadata()
catalogueElementPropertiesProvider.configureProperty 'containedIn', label: 'Models', columns: nameAndIdAndMetadata()
catalogueElementPropertiesProvider.configureProperty 'hasAttachmentOf', label: 'Attachments', columns: attachmentColumns()
catalogueElementPropertiesProvider.configureProperty 'hasContextOf', label: 'Conceptual Domains', columns: nameAndIdent()

catalogueElementPropertiesProvider.configureProperty 'includedIn', label: 'Conceptual Domains', columns: nameAndIdent()
catalogueElementPropertiesProvider.configureProperty 'instantiates', label: 'Data Elements' , columns: nameAndIdent()
catalogueElementPropertiesProvider.configureProperty 'instantiates', label: 'Data Elements' , columns: nameAndIdAndMetadata()

catalogueElementPropertiesProvider.configureProperty 'history', {
hidden: (security) ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import org.modelcatalogue.core.EnumeratedType
import org.modelcatalogue.core.MeasurementUnit
import org.modelcatalogue.core.Model
import org.modelcatalogue.core.PublishedElementStatus
import org.modelcatalogue.core.Relationship
import org.modelcatalogue.core.ValueDomain

class DataImportService {
Expand Down Expand Up @@ -195,7 +196,7 @@ class DataImportService {
importDataElement([name: row.dataElementName, description: row.dataElementDescription, modelCatalogueId: row.dataElementCode], row.metadata, model, [name: row.dataElementName.replaceAll("\\s", "_"), description: row.dataType.toString().take(2000), dataType: dataType, measurementUnit: measurementUnit], conceptualDomain)
} else {
//doesn't have a value domain so easy
importDataElement([name: row.dataElementName, description: row.dataElementDescription, modelCatalogueId: row.dataElementCode], row.metadata, model)
importDataElement([name: row.dataElementName, description: row.dataElementDescription, modelCatalogueId: row.dataElementCode], row.metadata, model, conceptualDomain)
}
}
if(!bulkIngest) importer.removeFromImportQueue(row)
Expand Down Expand Up @@ -401,7 +402,8 @@ class DataImportService {
ValueDomain vd = ValueDomain.findByDataTypeAndUnitOfMeasure(vdParams.dataType, vdParams.unitOfMeasure)
if (!vd) { vd = new ValueDomain(vdParams).save() }
vd.addToIncludedIn(cd)
vd.addToInstantiates(dataElement)
Relationship instantiated = vd.addToInstantiates(dataElement)
instantiated.ext.put("Context" , cd.name)
vd.save()
}

Expand All @@ -427,13 +429,14 @@ class DataImportService {
}

importValueDomain(vdParams, de, cd)
de.addToContainedIn(model)
Relationship containedIn = de.addToContainedIn(model)
containedIn.ext.put("Context" , cd.name)

return de
}


protected DataElement importDataElement(Map params, Map metadata, Model model) {
protected DataElement importDataElement(Map params, Map metadata, Model model, ConceptualDomain cd) {

//find out if data element exists using unique code
DataElement de = DataElement.findByModelCatalogueId(params.modelCatalogueId)
Expand All @@ -454,7 +457,10 @@ class DataImportService {
de = updateMetadata(metadata, de)
}

if(de){de.addToContainedIn(model)}
if(de){
Relationship containedIn = de.addToContainedIn(model)
containedIn.ext.put("Context" , cd.name)
}
return de
}

Expand All @@ -476,18 +482,18 @@ class DataImportService {


def importDataType(String name, String data) {
DataType dataTypeReturn = importEnumeratedType(data)
DataType dataTypeReturn = importEnumeratedType(data, name)
if(!dataTypeReturn) dataTypeReturn = DataType.findByName(data)
if(!dataTypeReturn) dataTypeReturn = DataType.findByNameIlike(data)
return dataTypeReturn
}

protected static EnumeratedType importEnumeratedType(String data){
protected static EnumeratedType importEnumeratedType(String data, String name){
def dataTypeReturn, sortedData
if (data.contains("|")) {
try { sortedData = sortEnumAsString(data) } catch (Exception e) { return null }
dataTypeReturn = EnumeratedType.findByEnumAsString(sortedData)
if (!dataTypeReturn) { dataTypeReturn = new EnumeratedType(name: ( (sortedData.size()>20) ? sortedData[0..20] : sortedData ) + "..", enumAsString: sortedData).save() }
if (!dataTypeReturn) { dataTypeReturn = new EnumeratedType(name: name, enumAsString: sortedData).save() }
} else if (data.contains("\n") || data.contains("\r")) {
String[] lines = data.split("\\r?\\n")
if (lines.size() > 0 && lines[] != null) {
Expand All @@ -514,7 +520,7 @@ class DataImportService {
}.join('|')
dataTypeReturn = EnumeratedType.findWhere(enumAsString: enumString)
if (!dataTypeReturn) {
dataTypeReturn = new EnumeratedType(name: ( (enumString.size()>20) ? enumString[0..20] : enumString ) + "..", enumerations: enumerations).save()
dataTypeReturn = new EnumeratedType(name: name, enumerations: enumerations).save()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ class DataImportSpec extends AbstractIntegrationSpec {

when:
def dataType = dataImportService.importDataType('testEnum', "t:test|t1:testONe")
def testDataType = DataType.findByName("t:test|t1:testONe..")
def testDataType = DataType.findByName("testEnum")

then:
dataType
Expand Down

0 comments on commit 4ee80b4

Please sign in to comment.