Skip to content

Commit

Permalink
Merge pull request #895 from MetadataConsulting/MET-1331-classifications
Browse files Browse the repository at this point in the history
Met 1331 classifications
  • Loading branch information
musketyr authored Feb 15, 2017
2 parents eed67a1 + 277f17d commit e1f463a
Show file tree
Hide file tree
Showing 81 changed files with 1,187 additions and 278 deletions.
7 changes: 2 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@ addons:
artifacts:
paths:
- $HOME/reports
apt:
packages:
- mysql-server-5.6
- mysql-client-core-5.6
- mysql-client-5.6
services:
- mysql
env:
- TEST_SUITE=functional
- TEST_SUITE=unit_and_integration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ angular.module('mc.core.ui.bs.catalogue', ['mc.core.catalogue']).config ['catalo
catalogueProvider.setIcon 'mapping', "fa fa-fw fa-superscript"
catalogueProvider.setIcon 'validationRule', "fa fa-fw fa-university"
catalogueProvider.setIcon 'dataModelPolicy', "fa fa-fw fa-check-square-o"
catalogueProvider.setIcon 'tag', "fa fa-fw fa-tag"

# this should be generated automatically in the future

Expand All @@ -44,6 +45,7 @@ angular.module('mc.core.ui.bs.catalogue', ['mc.core.catalogue']).config ['catalo
catalogueProvider.setInstanceOf 'model', 'catalogueElement'
catalogueProvider.setInstanceOf 'dataElement', 'catalogueElement'
catalogueProvider.setInstanceOf 'validationRule', 'catalogueElement'
catalogueProvider.setInstanceOf 'tag', 'catalogueElement'

catalogueProvider.setInstanceOf 'enumeratedType', 'dataType'
catalogueProvider.setInstanceOf 'referenceType', 'dataType'
Expand Down Expand Up @@ -145,6 +147,14 @@ angular.module('mc.core.ui.bs.catalogue', ['mc.core.catalogue']).config ['catalo

return 0.5 if list.base.indexOf("/asset") >= 0

return 0
]
catalogueProvider.addContainsCandidateTest ['list', 'element', 'extra', (list, newElement, extra) ->
return 0 unless list
return 0 unless list.base

return 0.5 if list.base.indexOf("/tag/forDataModel") >= 0 and newElement.isInstanceOf('dataElement')

return 0
]
]
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ angular.module('mc.core.ui.bs.catalogueElementProperties', []).config ['catalogu
catalogueElementPropertiesProvider.configureProperty 'ext', label: 'Metadata'
catalogueElementPropertiesProvider.configureProperty 'contextFor', label: 'Rules'
catalogueElementPropertiesProvider.configureProperty 'involvedIn', label: 'Rules'
catalogueElementPropertiesProvider.configureProperty 'tags', label: 'Data Elements'
catalogueElementPropertiesProvider.configureProperty 'childOf', label: 'Parents', columns: nameAndIdent()
catalogueElementPropertiesProvider.configureProperty 'isContextFor', label: 'Data Classes', columns: nameAndIdent()
catalogueElementPropertiesProvider.configureProperty 'containedIn', label: 'Data Classes', columns: nameAndIdAndMetadata()
Expand Down Expand Up @@ -240,6 +241,7 @@ angular.module('mc.core.ui.bs.catalogueElementProperties', []).config ['catalogu
catalogueElementPropertiesProvider.configureProperty 'originalDataModels', hidden: true
catalogueElementPropertiesProvider.configureProperty 'internalModelCatalogueId', hidden: true
catalogueElementPropertiesProvider.configureProperty 'versionNumber', hidden: true
catalogueElementPropertiesProvider.configureProperty 'isTaggedBy', hidden: true

catalogueElementPropertiesProvider.configureProperty '$$relationship', tabDefinition: [ '$element', '$name', ($element, $name) ->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ angular.module('mc.core.ui.bs.columns', ['mc.util.names']).config ['columnsProvi
columnsProvider.registerColumns 'org.modelcatalogue.core.DataClass', modelIdNameAndDescriptionColumns()
columnsProvider.registerColumns 'org.modelcatalogue.core.DataElement', modelIdNameAndDescriptionColumns()
columnsProvider.registerColumns 'org.modelcatalogue.core.ValidationRule', modelIdNameAndDescriptionColumns()
columnsProvider.registerColumns 'org.modelcatalogue.core.Tags', modelIdNameAndDescriptionColumns()

# special

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,4 +470,59 @@ x in ['apple', 'banana', 'cherry']
]
}
}

detailSectionsProvider.register {
title: 'Tags'
position: 70
types: [
'dataElement'
]
keys: []
template: '/mc/core/ui/detail-sections/tableData.html'
actions: [
{
label: 'Add Tag'
name: 'add'
icon: 'fa fa-plus-circle text-success'
action: (messages, element) ->
messages.prompt('Add Tag', '',
{
type: 'create-new-relationship'
element: element
relationshipTypeName: 'tag'
direction: "destinationToSource"
}
)
}
]

getList: (element) ->
return @result if @result

@result =
base: element.isTaggedBy.base
itemType: element.isTaggedBy.itemType

element.isTaggedBy(null, max: LIST_MAX).then (list) =>
@result = list
return @result
reorder: reorderInDetail('isTaggedBy')
data: {
columns:
[
{
header: 'Name'
value: "ext.get('name') || ext.get('Name') || relation.name "
classes: 'col-md-6'
href: 'relation.href()'
}
{
header: 'Description'
value: "relation.description"
classes: 'col-md-6'
textEllipsis: true
}
]
}
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ angular.module('mc.core.ui.bs', [
'mc.core.ui.bs.modalPromptBasicEdit'
'mc.core.ui.bs.modalPromptMeasurementUnitEdit'
'mc.core.ui.bs.modalPromptEnumeratedTypeEdit'
'mc.core.ui.bs.modalPromptTagEdit'
'mc.core.ui.bs.modalPromptActionParametersEdit'
'mc.core.ui.bs.modalPromptModel'
'mc.core.ui.bs.modalPromptRelationshipTypeEdit'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
angular.module('mc.core.ui.bs.modalPromptTagEdit', ['mc.util.messages', 'mc.core.ui.bs.withClassificationCtrlMixin']).config ['messagesProvider', (messagesProvider)->
factory = [ '$uibModal', '$q', 'messages', ($uibModal, $q, messages) ->
(title, body, args) ->
if not args?.element? and not args?.create?
messages.error('Cannot create relationship dialog.', 'The element to be edited is missing.')
return $q.reject('Missing element argument!')

dialog = $uibModal.open {
windowClass: 'basic-edit-modal-prompt'
size: 'lg'
template: '''
<div class="modal-header">
<h4>''' + title + '''</h4>
</div>
<div class="modal-body">
<messages-panel messages="messages"></messages-panel>
<form role="form" ng-submit="saveElement()">
<div class="form-group" ng-if="!hideDataModels()">
<label for="dataModel"> Data Models</label>
<elements-as-tags elements="copy.dataModels"></elements-as-tags>
<input id="dataModel" placeholder="Data Model" ng-model="pending.dataModel" catalogue-element-picker="dataModel" label="el.name" typeahead-on-select="addToDataModels()">
</div>
<div class="form-group">
<label for="name" class="">Name</label>
<input type="text" class="form-control" id="name" placeholder="Name" ng-model="copy.name">
</div>
<div class="form-group">
<label for="modelCatalogueId" class="">Catalogue ID</label>
<input type="text" class="form-control" id="modelCatalogueId" placeholder="e.g. external ID, namespace (leave blank for generated)" ng-model="copy.modelCatalogueId">
</div>
<div class="form-group">
<label for="description" class="">Description</label>
<textarea rows="10" ng-model="copy.description" placeholder="Description" class="form-control" id="description"></textarea>
</div>
<fake-submit-button/>
</form>
</div>
<div class="modal-footer">
<contextual-actions role="modal"></contextual-actions>
</div>
'''
controller: ['$scope', 'messages', '$controller', '$uibModalInstance', ($scope, messages, $controller, $uibModalInstance) ->
$scope.pending = {dataModel: null}
$scope.newEntity = -> {dataModels: $scope.copy?.dataModels ? []}
$scope.copy = angular.copy(args.element ? $scope.newEntity())
$scope.original = args.element ? {}
$scope.messages = messages.createNewMessages()
$scope.create = args.create
$scope.currentDataModel = args.currentDataModel

angular.extend(this, $controller('withClassificationCtrlMixin', {$scope: $scope}))
angular.extend(this, $controller('saveAndCreateAnotherCtrlMixin', {$scope: $scope, $uibModalInstance: $uibModalInstance}))

$scope.hasChanged = ->
$scope.copy.name != $scope.original.name\
or $scope.copy.description != $scope.original.description\
or $scope.copy.modelCatalogueId != $scope.original.modelCatalogueId

]

}

dialog.result
]

messagesProvider.setPromptFactory 'edit-tag', factory
]
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ angular.module('mc.core.ui.catalogueElementView', ['mc.core.catalogueElementEnha
or $scope.element?.isInstanceOf('measurementUnit')\
or $scope.element?.isInstanceOf('dataElement')\
or $scope.element?.isInstanceOf('validationRule')\
or $scope.element?.isInstanceOf('tag')\
)\
and ($scope.element?.status == 'DRAFT' or security.hasRole('SUPERVISOR'))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,13 @@ angular.module('mc.core.ui.metadataEditor', ['mc.core.ui.metadataEditors']).dire
$scope.handledKeys = []

onObjectChanged = (object) ->
if object and not isOrderedMap(object)
$log.error "Object", object, "is not ordered map"
return
if object
unless isOrderedMap(object)
$log.error "Object", object, "is not ordered map"
return

object.clearIfOnlyContainsPlaceholder()
object.addPlaceholderIfEmpty()
object.clearIfOnlyContainsPlaceholder()
object.addPlaceholderIfEmpty()

onObjectChanged($scope.object)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ angular.module('mc.core.ui.states.controllers.DataModelTreeCtrl', ['ui.router',

if element.resource
if element.getDataModelId() == currentDataModel?.id
if element.tagId
if element.tagId == 'none'
$state.go 'mc.resource.list', dataModelId: currentDataModel?.id, resource: 'dataElement', status: 'active', tag: 'none'
return
$state.go 'mc.resource.show.property', dataModelId: currentDataModel?.id, resource: 'tag', id: element.tagId, property: 'tags'
return
if element.resource == 'catalogueElement' && element.name == 'Deprecated Items'
$state.go 'mc.resource.list', dataModelId: currentDataModel?.id, resource: element.resource, status: 'deprecated'
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ angular.module('mc.core.ui.states.mc.resource.list', ['mc.core.ui.states.control
DEFAULT_ITEMS_PER_PAGE = 25

$stateProvider.state 'mc.resource.list', {
url: '/all?page&order&sort&status&q&max&classification&display'
url: '/all?page&order&sort&status&q&max&classification&display&tag'

views:
"":
Expand All @@ -31,6 +31,7 @@ angular.module('mc.core.ui.states.mc.resource.list', ['mc.core.ui.states.control
params.status = $stateParams.status
params.max = $stateParams.max ? DEFAULT_ITEMS_PER_PAGE
params.classification = $stateParams.classification ? undefined
params.tag = $stateParams.tag ? undefined

if $stateParams.dataModelId and $stateParams.dataModelId != 'catalogue'
params.dataModel = $stateParams.dataModelId
Expand All @@ -43,4 +44,4 @@ angular.module('mc.core.ui.states.mc.resource.list', ['mc.core.ui.states.control

}

])
])
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
xmlns:mdr="http://www.metadataregistry.org.uk/assets/schema/2.1/metadataregistry.xsd"
xmlns:mdr="http://www.metadataregistry.org.uk/assets/schema/2.2/metadataregistry.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.metadataregistry.org.uk/assets/schema/2.1/metadataregistry.xsd"
targetNamespace="http://www.metadataregistry.org.uk/assets/schema/2.2/metadataregistry.xsd"
elementFormDefault="qualified" version="1.0" xml:lang="EN">

<xs:simpleType name="SemanticVersion">
Expand Down
Loading

0 comments on commit e1f463a

Please sign in to comment.