Skip to content

Commit

Permalink
Merge pull request #1204 from MetadataConsulting/test/2.3.0.9
Browse files Browse the repository at this point in the history
Test/2.3.0.9
  • Loading branch information
johncross authored Apr 12, 2018
2 parents 5fe5704 + 123141a commit 0114eea
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 193 deletions.
2 changes: 1 addition & 1 deletion ModelCatalogueCorePluginTestApp/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
app.grails.version=2.5.6
app.name=ModelCatalogueCorePluginTestApp
app.servlet.version=3.0
app.version=2.2.5
app.version=T.2.3.0.9-debug
68 changes: 33 additions & 35 deletions ModelCatalogueCorePluginTestApp/grails-app/conf/Config.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -200,28 +200,25 @@ environments {
// ---
grails.logging.jul.usebridge = false
println "ServerURL:" + grails.serverURL
println "MC_SERVER_URL:" + System.getenv('MC_SERVER_URL')
grails.serverURL = System.getenv('MC_SERVER_URL')//"https://localhost:8899/mc"
println "MDX_SERVER_URL:" + System.getenv('MDX_SERVER_URL')
grails.serverURL = System.getenv('MDX_SERVER_URL')//"https://localhost:8899/mc"
//println "ServerURL:" + grails.serverURL
println "ServerURL:${grails.serverURL} END"
println "MC_DB_URL:" + System.getenv('MC_DB_URL')
println "MC_DB_USERNAME:" + System.getenv('MC_DB_USERNAME')
println "MC_DB_PASSWORD:" + System.getenv('MC_DB_PASSWORD')
println "MC_ELASTIC_HOST:" + System.getenv('MC_ELASTIC_HOST')
println "MC_ELASTIC_PORT:" + System.getenv('MC_ELASTIC_PORT')
println "MC_MAIL_FROM:" + System.getenv('MC_MAIL_FROM')
println "MC_MAIL_HOST:" + System.getenv('MC_MAIL_HOST')
println "MC_MAIL_PORT:" + System.getenv('MC_MAIL_PORT')
println "MC_MAIL_USERNAME:" + System.getenv('MC_MAIL_USERNAME')
println "MC_MAIL_PASSWORD:" + System.getenv('MC_MAIL_PASSWORD')
println "MC_NAME:" + System.getenv('MC_NAME')
println "MC_WELCOME:" + System.getenv('MC_WELCOME')
println "MC_INFO:" + System.getenv('MC_INFO')
println "MC_ALLOW_SIGNUP:" + System.getenv('MC_ALLOW_SIGNUP')

MC_ES_HOST
MC_ES_DELAY_AFTER_BATCH
MC_ES_ELEMENTS_PER_BATCH
//System.getenv('MDX_DB_URL')
println "MDX_DB_URL:" + System.getenv('MDX_DB_URL')
println "MDX_DB_USERNAME:" + System.getenv('MDX_DB_USERNAME')
println "MDX_DB_PASSWORD:" + System.getenv('MDX_DB_PASSWORD')
println "MDX_ELASTIC_HOST:" + System.getenv('MDX_ELASTIC_HOST')
println "MDX_ELASTIC_PORT:" + System.getenv('MDX_ELASTIC_PORT')
println "MDX_MAIL_FROM:" + System.getenv('MC_MAIL_FROM')
println "MDX_MAIL_HOST:" + System.getenv('MDX_MAIL_HOST')
println "MDX_MAIL_PORT:" + System.getenv('MDX_MAIL_PORT')
println "MDX_MAIL_USERNAME:" + System.getenv('MDX_MAIL_USERNAME')
println "MDX_MAIL_PASSWORD:" + System.getenv('MDX_MAIL_PASSWORD')
println "MDX_NAME:" + System.getenv('MDX_NAME')
println "MDX_WELCOME:" + System.getenv('MDX_WELCOME')
println "MDX_INFO:" + System.getenv('MDX_INFO')
println "MDX_ALLOW_SIGNUP:" + System.getenv('MDX_ALLOW_SIGNUP')

grails.plugin.springsecurity.auth.loginFormUrl = grails.serverURL + "/login/auth"
println grails.serverURL + "/login/ajaxSuccess"
Expand All @@ -235,18 +232,18 @@ environments {

grails.plugin.console.enabled=true
mc.legacy.dataModels=true
grails.mail.default.from = System.getenv("MC_MAIL_FROM")//"admin@datalink.org.uk"//System.getenv("MC_MAIL_FROM")
grails.plugin.springsecurity.ui.register.emailFrom = System.getenv("MC_MAIL_FROM")//"david@metadataconsulting.co.uk"//System.getenv("MC_MAIL_FROM")
grails.plugin.springsecurity.ui.forgotPassword.emailFrom = System.getenv("MC_MAIL_FROM")//"david@metadataconsulting.co.uk"//System.getenv("MC_MAIL_FROM")
grails.mail.default.from = System.getenv("MDX_MAIL_FROM")//"admin@datalink.org.uk"//System.getenv("MC_MAIL_FROM")
grails.plugin.springsecurity.ui.register.emailFrom = System.getenv("MDX_MAIL_FROM")//"david@metadataconsulting.co.uk"//System.getenv("MC_MAIL_FROM")
grails.plugin.springsecurity.ui.forgotPassword.emailFrom = System.getenv("MDX_MAIL_FROM")//"david@metadataconsulting.co.uk"//System.getenv("MC_MAIL_FROM")

grails {
mail {
host = System.getenv('MDX_MAIL_HOST')//"vps.beenleigh.com"
port = System.getenv('MDX_MAIL_PORT')//"25" as Integer
username = System.getenv('MDX_MAIL_USERNAME')//"testadmin@datalink.org.uk"//System.getenv("MC_MAIL_USERNAME")
password = System.getenv('MDX_MAIL_PASSWORD')//"adm1nAtB33nl31gh"//System.getenv("MC_MAIL_PASSWORD")
if (System.getenv("MC_MAIL_PROPS")) {
props = new JsonSlurper().parseText(System.getenv("MC_MAIL_PROPS"))
if (System.getenv("MDX_MAIL_PROPS")) {
props = new JsonSlurper().parseText(System.getenv("MDX_MAIL_PROPS"))
}
}
}
Expand Down Expand Up @@ -282,20 +279,21 @@ environments {
]


if (System.properties["mc.config.location"]) {
// for running
// grails prod run-war -Dmc.config.location=my-conf.groovy
grails.config.locations = ["file:" + System.properties["mc.config.location"]]
} else {
grails.config.locations = [ "classpath:mc-config.properties",
"classpath:mc-config.groovy",
"file:${userHome}/.grails/mc-config.properties",
"file:${userHome}/.grails/mc-config.groovy"]
}
// if (System.properties["mc.config.location"]) {
// // for running
// // grails prod run-war -Dmc.config.location=my-conf.groovy
// grails.config.locations = ["file:" + System.properties["mc.config.location"]]
// } else {
// grails.config.locations = [ "classpath:mc-config.properties",
// "classpath:mc-config.groovy",
// "file:${userHome}/.grails/mc-config.properties",
// "file:${userHome}/.grails/mc-config.groovy"]
// }
if (System.properties['catalina.base']) {
def tomcatConfDir = new File("${System.properties['catalina.base']}/conf")
if (tomcatConfDir.isDirectory()) {
grails.config.locations = ["file:${tomcatConfDir.canonicalPath}/mc-config.groovy"]

}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.modelcatalogue.core

import grails.gorm.DetachedCriteria
import grails.plugin.springsecurity.SpringSecurityUtils
import org.modelcatalogue.core.asset.MicrosoftOfficeDocument
import org.modelcatalogue.core.persistence.AssetGormService
import org.modelcatalogue.core.util.ParamArgs
Expand Down Expand Up @@ -88,6 +89,10 @@ class DataModelController<T extends CatalogueElement> extends AbstractCatalogueE
dataModelGormService.findById(id)
}

def showAssetInAngular() {
redirect(url: "/#/${params.id}/asset/${params.subResourceId}")
}

/**
* Saves a resource
* Overrides the base method - there is a slightly different security model
Expand Down Expand Up @@ -743,12 +748,6 @@ class DataModelController<T extends CatalogueElement> extends AbstractCatalogueE
protected ListWrapper<DataModel> findUnfilteredEffectiveItems(Integer max) {
//if you only want the active data models (draft and finalised)
if (params.status?.toLowerCase() == 'active') {
//if you have the role viewer you can see drafts
if (modelCatalogueSecurityService.hasRole('VIEWER')) {
return dataModelService.classified(withAdditionalIndexCriteria(Lists.fromCriteria(params, resource, "/${resourceName}/") {
'in' 'status', [ElementStatus.FINALIZED, ElementStatus.DRAFT, ElementStatus.PENDING]
}), overridableDataModelFilter)
}
//if not you can only see finalised models
return dataModelService.classified(withAdditionalIndexCriteria(Lists.fromCriteria(params, resource, "/${resourceName}/") {
'eq' 'status', ElementStatus.FINALIZED
Expand All @@ -760,14 +759,13 @@ class DataModelController<T extends CatalogueElement> extends AbstractCatalogueE
//then return the models by the status - providing you have the correct role
if (params.status) {
return dataModelService.classified(withAdditionalIndexCriteria(Lists.fromCriteria(params, resource, "/${resourceName}/") {
'in' 'status', ElementService.getStatusFromParams(params, modelCatalogueSecurityService.hasRole('VIEWER'))
'in' 'status', ElementService.getStatusFromParams(params)
}), overridableDataModelFilter)
}

return dataModelService.classified(withAdditionalIndexCriteria(Lists.all(params, resource, "/${resourceName}/")), overridableDataModelFilter)
}


protected ListWrapper<DataModel> filterUnauthorized(ListWrapper<DataModel> items) {
if ( items instanceof ListWithTotalAndTypeWrapper ) {
ListWithTotalAndTypeWrapper listWithTotalAndTypeWrapperInstance = (ListWithTotalAndTypeWrapper) items
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class SearchController extends AbstractRestfulController<CatalogueElement> {

boolean soft = params.boolean('soft')
executorService.submit {
modelCatalogueSearchService.reindex(soft).toBlocking().subscribe(LoggingSubscriber.create(log, "... reindexing finished", "Error reindexing the catalogue"))
modelCatalogueSearchService.reindex(soft).toBlocking().subscribe(LoggingSubscriber.create(log, "... reindexing finished", "Error reindexing the catalogue"))
}

if(request.getHeader('Accept')?.contains('application/json')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -564,44 +564,45 @@ class ElasticSearchService implements SearchCatalogue {
@Override
Observable<Boolean> reindex(boolean soft) {

log.info "Reindexing start"
deleteIndexes()

log.info "Reindexing deleteIndexes"
IndexingSession session = IndexingSession.create()

log.info "Reindexing IndexingSession.create"
//index Data Models
indexDomains(DataModel, session)

log.info "Reindexing starindexDomains(DataModel, session)t"
//index DataClasses
indexDomains(DataClass, session)

log.info "Reindexing indexDomains(DataClass, session)"
//Index Data Element
indexDomains(DataElement, session)

log.info "Reindexing indexDomains(DataElement, session)"
//Index Data Types
indexDomains(DataType, session)

log.info "Reindexing indexDomains(DataType, session)"
//Index Measurement Units
indexDomains(MeasurementUnit, session)

log.info "Reindexing indexDomains(MeasurementUnit, session)"
//Index Tags
indexDomains(Tag, session)

log.info "Reindexing indexDomains(Tag, session)"
//Index DataModelPolicy
indexDomains(DataModelPolicy, session)

log.info "Reindexing indexDomains(DataModelPolicy, session)"
//Index Asset
indexDomains(Asset, session)

log.info "Reindexing indexDomains(Asset, session)"
//Index RelationshipType
indexDomains(RelationshipType, session)

log.info "Reindexing indexDomains(RelationshipType, session)"
//Index Users
indexDomains(User, session)

log.info "Reindexing indexDomains(User, session)"
//index relationships that are searchable i.e. favourites
def query = Relationship.where { (relationshipType.searchable == true) }
indexSimpleIndexRequestsInBatches(session, query.list())

log.info "Reindexing indexSimpleIndexRequestsInBatches(session, query.list())"
return Observable.just(true)

}
Expand Down Expand Up @@ -644,12 +645,15 @@ class ElasticSearchService implements SearchCatalogue {

batch.eachWithIndex { element, i ->
singleRequests.add(toSimpleIndexRequests(session, element))

//split indexing into batches
if ((i + 1) % ELEMENTS_PER_BATCH == 0 || (i + 1) == count) {
//TODO: can we get rid of placeholder for last
println "Index " + element.toString() + i
try {
indexSimpleIndexRequests(singleRequests).toBlocking().last()
singleRequests.clear()
println "Clear" + i
}catch(Error e){
log.error e
}
Expand Down Expand Up @@ -752,7 +756,7 @@ class ElasticSearchService implements SearchCatalogue {
// ignore and keep the latest
continue
}
//return Observable.error(new RuntimeException("There were error indexing at least of one item from the batch: $response.type#$response.id@$response.index", response.failure.cause))
return Observable.error(new RuntimeException("There were error indexing at least of one item from the batch: $response.type#$response.id@$response.index", response.failure.cause))
}
}
return just(it)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<form action="/api/modelCatalogue/core/search/reindex" method="post">
<p>Whole catalogue will be reindexed. This may take a long time and it can have negative impact on the performance.</p>
<input type="submit" value="Reindex catalogue" class="btn btn-default"/>
<g:hiddenField name="soft" value="true" />
</form>

</div><!-- /.panel-body -->
Expand Down
Loading

0 comments on commit 0114eea

Please sign in to comment.