Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
Conflicts:
	ModelCatalogueCorePlugin/ModelCatalogueCorePluginGrailsPlugin.groovy
	ModelCatalogueCorePlugin/application.properties
  • Loading branch information
amilward committed May 29, 2014
2 parents 014c5ae + adc03c7 commit a204bd3
Show file tree
Hide file tree
Showing 26 changed files with 372 additions and 163 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,9 @@ angular.module("mc.core.modelCatalogueDataArchitect", ['mc.util.rest', 'mc.util.
params = angular.extend({key: query}, additionalParams)
enhance rest method: 'GET', url: "#{modelCatalogueApiRoot}/dataArchitect/metadataKeyCheck", params: params

modelCatalogueDataArchitect.findRelationsByMetadataKeys = (query, query2, additionalParams = {}) ->
params = angular.extend({keyOne: query}, {keyTwo: query2}, additionalParams)
enhance rest method: 'GET', url: "#{modelCatalogueApiRoot}/dataArchitect/findRelationsByMetadataKeys", params: params

modelCatalogueDataArchitect
]
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ angular.module('mc.core.ui.bs.catalogueElementTreeview', ['mc.core.ui.catalogueE
<catalogue-element-treeview-item element="item" descend="descend" root-id="id" repeat="repeat" ng-repeat="item in children"></catalogue-element-treeview-item>
<li ng-switch-when="list" ng-if="hasMore" class="catalogue-element-treeview-item">
<span class="catalogue-element-treeview-labels" ng-click="showMore()">
<a ng-click="showMore()" class="btn btn-link"><span class="glyphicon glyphicon-chevron-down"></span></a> <a ng-click="showMore()">Show more</a>
<a class="btn btn-link"><span class="glyphicon glyphicon-chevron-down"></span></a> <a>Show more</a>
</span>
</li>
<catalogue-element-treeview-item element="element" descend="descend" root-id="id" repeat="repeat" ng-switch-when="element"></catalogue-element-treeview-item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ angular.module('mc.core.ui.bs.catalogueElementTreeviewItem', ['mc.core.ui.catalo
<span class="catalogue-element-treeview-labels" ng-dblclick="element.show()">
<span ng-if="!element.elementType"><a class="btn btn-link"><span class="glyphicon glyphicon-ban-circle"></span></a> No Data</span>
<a ng-if="currentDescend &amp;&amp; element.elementType" ng-click="collapseOrExpand()" class="btn btn-link">
<span class="glyphicon glyphicon-folder-close" ng-if="collapsed"></span>
<span class="glyphicon glyphicon-folder-open" ng-if="!collapsed"></span>
<span class="glyphicon glyphicon-folder-close" ng-if="collapsed &amp;&amp; !loadingChildren"></span>
<span class="glyphicon glyphicon-folder-open" ng-if="!collapsed &amp;&amp; !loadingChildren"></span>
<span class="glyphicon glyphicon-refresh" ng-if="loadingChildren"></span>
</a>
<a ng-if="!currentDescend &amp;&amp; element.elementType" class="btn btn-link">
<span class="glyphicon glyphicon-file"></span>
Expand All @@ -20,7 +21,7 @@ angular.module('mc.core.ui.bs.catalogueElementTreeviewItem', ['mc.core.ui.catalo
<catalogue-element-treeview-item element="child" descend="nextDescend" repeat="repeat" ng-repeat="child in children track by $index" root-id="rootId"></catalogue-element-treeview-item>
<li ng-if="hasMore" class="catalogue-element-treeview-item">
<span class="catalogue-element-treeview-labels" ng-click="showMore()">
<a ng-click="showMore()" class="btn btn-link"><span class="glyphicon glyphicon-chevron-down"></span></a> <a ng-click="showMore()">Show more</a>
<a class="btn btn-link"><span class="glyphicon glyphicon-chevron-down"></span></a> <a>Show more</a>
</span>
</li>
</ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ angular.module('mc.core.ui.catalogueElementTreeviewItem', ['mc.util.names', 'mc.

compile: recursiveCompile.compile

controller: ['$scope', '$rootScope', ($scope, $rootScope) ->
loadingChildren = false
controller: ['$scope', '$rootScope', '$log', ($scope, $rootScope, $log) ->
$scope.loadingChildren = false

isEqual = (a, b) ->
return false if not a? or not b?
Expand All @@ -23,9 +23,12 @@ angular.module('mc.core.ui.catalogueElementTreeviewItem', ['mc.util.names', 'mc.

createShowMore = (list) ->
->
$log.info "this is ", this
list.next().then (nextList) ->
$log.info "adding items to children ", $scope.children, " from ", nextList
for item in nextList.list
$scope.children.push(item.relation)
$log.info "new children are", $scope.children
$scope.hasMore = $scope.numberOfChildren > $scope.children.length
$scope.showMore = createShowMore(nextList)

Expand Down Expand Up @@ -80,10 +83,10 @@ angular.module('mc.core.ui.catalogueElementTreeviewItem', ['mc.util.names', 'mc.
$scope.numberOfChildren--

$scope.collapseOrExpand = ->
return if loadingChildren
return if $scope.loadingChildren
if $scope.collapsed
if $scope.children.length == 0 and $scope.numberOfChildren > 0
loadingChildren = true
$scope.loadingChildren = true
fun = $scope.element[$scope.currentDescend]
if angular.isFunction(fun)
fun().then (list) ->
Expand All @@ -99,9 +102,9 @@ angular.module('mc.core.ui.catalogueElementTreeviewItem', ['mc.util.names', 'mc.
$scope.showMore = createShowMore(list)
else
$scope.showMore = ->
loadingChildren = false
$scope.loadingChildren = false
else
loadingChildren = false
$scope.loadingChildren = false
else
$scope.collapsed = false
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ angular.module('mc.core.ui.catalogueElementView', ['mc.core.catalogueElementEnha
$state.go 'mc.resource.show.property', {resource: names.getPropertyNameFromType($scope.element.elementType), id: $scope.element.id, property: newProperty, page: page}, options if $scope.element

onElementUpdate = (element) ->
resource = catalogueElementResource(element.elementType) if element
resource = catalogueElementResource(element.elementType) if element and element.elementType

activeTabSet = false

Expand Down Expand Up @@ -125,6 +125,10 @@ angular.module('mc.core.ui.catalogueElementView', ['mc.core.catalogueElementEnha
isDirty: () -> angular.equals(@original, @value)
reset: () -> @value = angular.copy @original
update: () ->
if not resource
messages.error("Cannot update property #{names.getNaturalName(self.name)} of #{element.name}. See application logs for details.")
return

payload = {
id: element.id
}
Expand Down Expand Up @@ -177,7 +181,7 @@ angular.module('mc.core.ui.catalogueElementView', ['mc.core.catalogueElementEnha
tabDefinition.active = true
activeTabSet = true
if element.elementTypeName == 'Model'
$scope.reports = [{name: "exportAll COSD", url: modelCatalogueApiRoot + "/dataArchitect/getSubModelElements/" + element.id + "?format=xlsx&report=COSD"}, {name: "exportAll NHIC", url: modelCatalogueApiRoot + "/dataArchitect/getSubModelElements/" + element.id + "?format=xlsx&report=NHIC"}]
$scope.reports = [{name: "exportAll COSD", url: modelCatalogueApiRoot + "/dataArchitect/getSubModelElements/" + element.id + "?format=xlsx&report=COSD"}, {name: "exportAll NHIC", url: modelCatalogueApiRoot + "/dataArchitect/getSubModelElements/" + element.id + "?format=xlsx&report=NHIC"},{name: "exportAll XML", url: modelCatalogueApiRoot + "/dataArchitect/getSubModelElements/" + element.id + "?format=xml"}]

tabs.unshift tabDefinition

Expand Down Expand Up @@ -211,9 +215,11 @@ angular.module('mc.core.ui.catalogueElementView', ['mc.core.catalogueElementEnha
messages.prompt('Create Relationship', '', {type: 'new-relationship', element: $scope.element})

$scope.canEdit = ->
return false if not $scope.element
messages.hasPromptFactory('edit-' + names.getPropertyNameFromType($scope.element.elementType))

$scope.edit = ->
return if not $scope.element
messages.prompt('Edit ' + $scope.element.elementTypeName, '', {type: 'edit-' + names.getPropertyNameFromType($scope.element.elementType), element: $scope.element}).then (updated)->
$scope.element = updated

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ angular.module('mc.core.ui.states.defaultStates', ['ui.router'])
$scope.title = names.getNaturalName($stateParams.resource)
$scope.natural = (name) -> if name then names.getNaturalName(name) else "General"
$scope.resource = $stateParams.resource
$scope.containedElements = listEnhancer.createEmptyList('org.modelcatalogue.core.DataElement')
$scope.contained = {}
$scope.contained.elements = listEnhancer.createEmptyList('org.modelcatalogue.core.DataElement')
$scope.selectedElement = if list.size > 0 then list.list[0] else {name: 'No Selection'}
$scope.containedElementsColumns = [
$scope.contained.columns = [
{header: 'Name', value: "relation.name", classes: 'col-md-6', show: "relation.show()"}
{header: 'Description', value: "relation.description", classes: 'col-md-6'}
]
Expand All @@ -24,10 +25,17 @@ angular.module('mc.core.ui.states.defaultStates', ['ui.router'])
unless element._containedElements_?.empty
element.contains().then (contained)->
element._containedElements_ = contained
$scope.containedElements = contained
$scope.contained.elements = contained
$scope.selectedElement = element
$scope.containedElements = element._containedElements_ ? listEnhancer.createEmptyList('org.modelcatalogue.core.DataElement')
])
$scope.contained.elements = element._containedElements_ ? listEnhancer.createEmptyList('org.modelcatalogue.core.DataElement')

else if $scope.resource == 'newRelationships'
$scope.columns = [
{header: "source", value: 'source.name', class: 'col-md-6' }
{header: "destination", value: 'destination.name', class: 'col-md-6' }
]

])
.config(['$stateProvider', ($stateProvider) ->

DEFAULT_ITEMS_PER_PAGE = 10
Expand Down Expand Up @@ -80,7 +88,6 @@ angular.module('mc.core.ui.states.defaultStates', ['ui.router'])
templateUrl: 'modelcatalogue/core/ui/state/list.html'
resolve: {
list: ['$stateParams','modelCatalogueSearch', ($stateParams, modelCatalogueSearch) ->
page = parseInt($stateParams.page ? 1, 10)
$stateParams.resource = "dataElement"
return modelCatalogueSearch($stateParams.searchString)
]
Expand All @@ -100,7 +107,6 @@ angular.module('mc.core.ui.states.defaultStates', ['ui.router'])
templateUrl: 'modelcatalogue/core/ui/state/list.html'
resolve:
list: ['$stateParams', 'modelCatalogueDataArchitect', ($stateParams, modelCatalogueDataArchitect) ->
page = parseInt($stateParams.page ? 1, 10)
$stateParams.resource = "dataElement"
# it's safe to call top level for each controller, only model controller will respond on it
modelCatalogueDataArchitect.uninstantiatedDataElements()
Expand All @@ -109,6 +115,7 @@ angular.module('mc.core.ui.states.defaultStates', ['ui.router'])
controller: 'mc.core.ui.states.ListCtrl'
}


$stateProvider.state 'mc.dataArchitect.metadataKey', {
url: "/metadataKeyCheck",
templateUrl: 'modelcatalogue/core/ui/state/parent.html'
Expand Down Expand Up @@ -143,7 +150,6 @@ angular.module('mc.core.ui.states.defaultStates', ['ui.router'])
templateUrl: 'modelcatalogue/core/ui/state/list.html'
resolve:
list: ['$stateParams', 'modelCatalogueDataArchitect', ($stateParams, modelCatalogueDataArchitect) ->
page = parseInt($stateParams.page ? 1, 10)
$stateParams.resource = "dataElement"
# it's safe to call top level for each controller, only model controller will respond on it
return modelCatalogueDataArchitect.metadataKeyCheck($stateParams.metadata)
Expand All @@ -152,6 +158,50 @@ angular.module('mc.core.ui.states.defaultStates', ['ui.router'])
controller: 'mc.core.ui.states.ListCtrl'
}

$stateProvider.state 'mc.dataArchitect.findRelationsByMetadataKeys', {
url: "/findRelationsByMetadataKeys",
templateUrl: 'modelcatalogue/core/ui/state/parent.html',
controller: ['$scope','$state','$modal',($scope, $state, $modal)->
dialog = $modal.open {
windowClass: 'messages-modal-prompt'
template: '''
<div class="modal-header">
<h4>please enter metadata key</h4>
</div>
<div class="modal-body">
<form role="form">
<div class="form-group">
<label for="keyOne">metadata key one</label>
<input type="text" id="keyOne" ng-model="result.keyOne" class="form-control">
<label for="keyTwo">metadata key two</label>
<input type="text" id="keyTwo" ng-model="result.keyTwo" class="form-control">
</form>
</div>
<div class="modal-footer">
<button class="btn btn-primary" ng-click="$close(result)">OK</button>
<button class="btn btn-warning" ng-click="$dismiss()">Cancel</button>
</div>
'''
}

dialog.result.then (result) ->
$state.go('mc.dataArchitect.showMetadataRelations', {'keyOne':result.keyOne, 'keyTwo':result.keyTwo})
]
}

$stateProvider.state 'mc.dataArchitect.showMetadataRelations', {
url: "/showMetadataRelations/{keyOne}/{keyTwo}",
templateUrl: 'modelcatalogue/core/ui/state/list.html'
resolve:
list: ['$stateParams', 'modelCatalogueDataArchitect', ($stateParams, modelCatalogueDataArchitect) ->
$stateParams.resource = "newRelationships"
# it's safe to call top level for each controller, only model controller will respond on it
return modelCatalogueDataArchitect.findRelationsByMetadataKeys($stateParams.keyOne, $stateParams.keyTwo)
]

controller: 'mc.core.ui.states.ListCtrl'
}

])
.run(['$rootScope', '$state', '$stateParams', ($rootScope, $state, $stateParams) ->
# It's very handy to add references to $state and $stateParams to the $rootScope
Expand Down Expand Up @@ -180,7 +230,7 @@ angular.module('mc.core.ui.states.defaultStates', ['ui.router'])
</div>
</span>
<h2>{{title}} List</h2>
<decorated-list list="list"></decorated-list>
<decorated-list list="list" columns="columns"></decorated-list>
</div>
<div ng-if="resource == 'model'">
<div class="row">
Expand All @@ -192,7 +242,7 @@ angular.module('mc.core.ui.states.defaultStates', ['ui.router'])
<catalogue-element-treeview list="list" descend="'parentOf'"></catalogue-element-treeview>
</div>
<div class="col-md-8">
<decorated-list list="containedElements" columns="containedElementsColumns" stateless="true"></decorated-list>
<decorated-list list="contained.elements" columns="contained.columns" stateless="true"></decorated-list>
</div>
<hr/>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
angular.module( 'mc.util.names', []).service 'names', ->
names =
getNaturalName: (propertyName) ->
return null if not propertyName
(word[0].toUpperCase() + word[1..-1].toLowerCase() for word in propertyName.split /(?=[A-Z])(?=[A-Z])|\s+/g).join(' ').replace /([A-Z]) (?=([A-Z] ))/g, '$1'


getPropertyNameFromType: (type) ->
return null if not type
simpleName = if type.indexOf('.') > -1 then type.substring(type.lastIndexOf('.') + 1) else type
simpleName[0].toLowerCase() + simpleName[1..-1]

Expand Down
5 changes: 3 additions & 2 deletions ModelCatalogueCorePlugin/grails-app/conf/BuildConfig.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ grails.project.dependency.resolution = {
export = false
}

compile ":coffee-asset-pipeline:1.5.0"
compile ":less-asset-pipeline:1.5.0"
compile ":asset-pipeline:1.8.8"
compile ":coffee-asset-pipeline:1.8.0"
compile ":less-asset-pipeline:1.7.0"
compile ":hibernate:3.6.10.8"

compile ":excel-export:0.2.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ grails.doc.copyright = ''// The copyright message to display
grails.doc.footer = ''// The footer to use


grails.assets.minifyJs = false

//configured data types, measurement units, relationship types

Expand Down Expand Up @@ -135,7 +136,7 @@ modelcatalogue.defaults.relationshiptypes = [
[name: "inclusion", sourceToDestination: "includes", destinationToSource: "included in", sourceClass: ConceptualDomain, destinationClass: ValueDomain],
[name: "instantiation", sourceToDestination: "instantiated by", destinationToSource: "instantiates", sourceClass: DataElement, destinationClass: ValueDomain],
[name: "supersession", sourceToDestination: "superseded by", destinationToSource: "supersedes", sourceClass: PublishedElement, destinationClass: PublishedElement, rule: "source.class == destination.class", system: true],
[name: "relatedTo", sourceToDestination: "related to", destinationToSource: "related to", sourceClass: CatalogueElement, destinationClass: CatalogueElement]
[name: "relatedTo", sourceToDestination: "related to", destinationToSource: "related to", sourceClass: DataElement, destinationClass: DataElement]
]

// Uncomment and edit the following lines to start using Grails encoding & escaping improvements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ class ModelCatalogueCorePluginUrlMappings {
"/getSubModelElements/$modelId?" (controller:"dataArchitect"){
action = [GET: "getSubModelElements"]
}
"/findRelationsByMetadataKeys/$key?" (controller:"dataArchitect"){
action = [GET: "findRelationsByMetadataKeys"]
}

}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,66 @@ class DataArchitectController {
respond elements
}

def findRelationsByMetadataKeys(Integer max){
setSafeMax(max)
def results
def keyOne = params.keyOne
def keyTwo = params.keyTwo
if(keyOne && keyTwo) {
try {
results = dataArchitectService.findRelationsByMetadataKeys(keyOne, keyTwo, params)
} catch (Exception e) {
println(e)
return
}

//FIXME we need new method to do this and integrate it with the ui
try {
dataArchitectService.actionRelationshipList(results.list)
} catch (Exception e) {
println(e)
return
}

def baseLink = "/dataArchitect/findRelationsByMetadataKeys"
def links = ListWrapper.nextAndPreviousLinks(params, baseLink, results.count)

Elements elements = new Elements(
base: baseLink,
total: results.count,
items: results.list,
itemType: Relationship,
previous: links.previous,
next: links.next,
offset: params.int('offset') ?: 0,
page: params.int('max') ?: 10,
sort: params.sort,
order: params.order
)

respond elements

}else{
respond "please enter keys"
}

}


// def actionRelationships(){
//
// def relations = params.relatedElements
//
// try {
// def errors = dataArchitectService.createRelationshipByType(relations, "relatedTo")
// }
// catch (Exception ex) {
// //log.error("Exception in handling excel file: "+ ex.message)
// log.error("Exception in handling excel file")
// flash.message = "Error while creating relationships`.";
// }
//
// }

protected setSafeMax(Integer max) {
withFormat {
Expand Down
Loading

0 comments on commit a204bd3

Please sign in to comment.