Skip to content

Commit

Permalink
Merge pull request #139 from thehyve/trait_v2
Browse files Browse the repository at this point in the history
Merge The Hyve trait_v2 into PhenotypeFoundation master
  • Loading branch information
ferryjagers committed Oct 6, 2015
2 parents ce80eaf + 1a7067b commit b9fa9b4
Show file tree
Hide file tree
Showing 23 changed files with 304 additions and 254 deletions.
8 changes: 4 additions & 4 deletions grails-app/conf/Config.groovy
Expand Up @@ -266,9 +266,9 @@ gscf.baseURL = grails.serverURL
// Default configuration of manuals
gscf {
documents {
quickstart = "downloads/quickstart_study_capturing.pdf"
manual = "downloads/gscf_user_guide.pdf"
license = "downloads/license_terms.pdf"
sam_userguide = "downloads/SAM_User_Guide.pdf"
quickstart = "/downloads/quickstart_study_capturing.pdf"
manual = "/downloads/gscf_user_guide.pdf"
license = "/downloads/license_terms.pdf"
sam_userguide = "/downloads/SAM_User_Guide.pdf"
}
}
10 changes: 5 additions & 5 deletions grails-app/conf/default.properties
@@ -1,6 +1,6 @@
## Server URL ##
grails.serverURL=http://localhost:8080/gscf
gscf.baseURL=http://localhost:8080/gscf/
gscf.baseURL=http://localhost:8080/gscf

## In-Memory Database ##
dataSource.driverClassName=org.h2.Driver
Expand Down Expand Up @@ -55,7 +55,7 @@ gscf.reCapitalizeSampleNames=true

# Locations of issues and documents
gscf.issueURL=https://github.com/PhenotypeFoundation/GSCF/issues
gscf.documents.quickstart=downloads/quickstart_study_capturing.pdf
gscf.documents.manual=downloads/gscf_user_guide.pdf
gscf.documents.license=downloads/license_terms.pdf
gscf.documents.sam_userguide=downloads/SAM_User_Guide.pdf
gscf.documents.quickstart=/downloads/quickstart_study_capturing.pdf
gscf.documents.manual=/downloads/gscf_user_guide.pdf
gscf.documents.license=/downloads/license_terms.pdf
gscf.documents.sam_userguide=/downloads/SAM_User_Guide.pdf
291 changes: 126 additions & 165 deletions grails-app/services/dbnp/studycapturing/AssayService.groovy

Large diffs are not rendered by default.

Expand Up @@ -291,13 +291,12 @@ class TemplateEditorController {
* On error the method gives a HTTP response status 500 and the error
*/
def updateTemplate = {
// set content type
response.setContentType("text/plain; charset=UTF-8")

// Search for the template field
def template = Template.get(params.id);
if (!template) {
response.status = 404;
response.setContentType("text/plain; charset=UTF-8")
render 'Template not found';
return;
}
Expand All @@ -307,11 +306,21 @@ class TemplateEditorController {
def version = params.version.toLong()
if (template.version > version) {
response.status = 500;
response.setContentType("text/plain; charset=UTF-8")
render 'Template was updated while you were working on it. Please reload and try again.';
return
}
}

// Check if the name already exists
def dupeCandidate = Template.findByName(params.name)
if (dupeCandidate && dupeCandidate != template) {
response.status = 500
response.setContentType("text/plain; charset=UTF-8")
render 'A template with that name already exists. Please choose a different name.'
return
}

template.properties = params
if (!template.hasErrors() && template.save(flush: true)) {
def html = g.render(plugin: 'gdt', template: 'elements/liTemplate', model: [template: template, templateadmin: authenticationService.getLoggedInUser().hasTemplateAdminRights()]);
Expand All @@ -320,6 +329,7 @@ class TemplateEditorController {
render output as JSON;
} else {
response.status = 500;
response.setContentType("text/plain; charset=UTF-8")
render 'Template was not updated because errors occurred.';
return
}
Expand Down Expand Up @@ -951,4 +961,4 @@ class TemplateEditorController {

return true;
}
}
}
12 changes: 11 additions & 1 deletion local-plugins/GDT/grails-app/domain/org/dbnp/gdt/Template.groovy
Expand Up @@ -105,7 +105,7 @@ class Template extends Identity {
this()

// copy base values
this.name = otherTemplate.name + " (Copy)"
this.name = createUniqueName(otherTemplate.name)
this.description = otherTemplate.description
this.entity = otherTemplate.entity

Expand All @@ -116,6 +116,16 @@ class Template extends Identity {
}
}

private static createUniqueName(name) {
def originalName = name
def i = 2
while (Template.findByName(name)) {
name = "${originalName} - ${i}"
i++
}
return name
}

/**
* clone template
* @param otherTemplate
Expand Down
14 changes: 10 additions & 4 deletions local-plugins/GDT/src/groovy/org/dbnp/gdt/TemplateEntity.groovy
Expand Up @@ -241,17 +241,23 @@ abstract class TemplateEntity extends Identity {
/**
* Retrieve a the value of a single field for a set of entities
*/
public getColumnForEntities( def entities, TemplateField field ) {
if( !entities )
public getColumnForEntities( def ids, TemplateField field ) {
if( !ids )
return []

def fieldType = field.type
String store = "template${fieldType.casedName}Fields"

def columnData = this.class.executeQuery( "SELECT e.id, store FROM " + this.class.simpleName + " e INNER JOIN e." + store + " store WHERE e in (:entities) AND index(store) = :fieldName", [entities: entities, fieldName: field.name ] )
def columnData
if( isDomainField(field) ) {
columnData = this.class.executeQuery( "SELECT e.id, e." + field.name + " FROM " + this.class.simpleName + " e WHERE e.id in (:ids)", [ids: ids] )
} else {
columnData = this.class.executeQuery( "SELECT e.id, store FROM " + this.class.simpleName + " e INNER JOIN e." + store + " store WHERE e.id in (:ids) AND index(store) = :fieldName", [ids: ids, fieldName: field.name ] )
}

def columnMap = columnData.collectEntries { [ (it[0]): it[1] ] }

entities.collect { it ? columnMap[ it.id ] : null }
ids.collect { it ? columnMap[ it ] : null }
}

/**
Expand Down
12 changes: 9 additions & 3 deletions local-plugins/GDT/web-app/js/templateEditor.js
Expand Up @@ -191,8 +191,14 @@ function updateTemplate( id ) {
updateTemplateListItem( id, data.html );
userMessage( 'Your template was updated.', "okay" );
},
error: function( request ) {
userMessage( "Could not update template", "errormessage" );
error: function( request, textStatus, error ) {
var contentType = request.getResponseHeader('content-type')
if (contentType.indexOf('text/plain') > -1) {
userMessage( "Could not update template: " + request.responseText, "errormessage" );
}
else {
userMessage( "Could not update template: " + error, "errormessage" );
}
},
complete: function( request, textStatus ) {
hideWaiting();
Expand Down Expand Up @@ -883,4 +889,4 @@ function updateOntologyLists( newObject) {
function deleteOntology( id ) {
$("#ontologies_" + id).children().remove(":selected");
return false;
}
}
1 change: 0 additions & 1 deletion local-plugins/SAM/grails-app/conf/SamResources.groovy
Expand Up @@ -7,7 +7,6 @@ modules = {
resource url: [dir: 'js', file: 'selectAddMore.js', plugin: 'dbxp-sam']
resource url: [dir: 'js', file: 'removeWebFlowExecutionKey.js', plugin: 'dbxp-sam']
resource url: [dir: 'css', file: 'sam.css', plugin: 'dbxp-sam']
resource url: [dir: 'css', file: 'tooltip.css', plugin: 'dbxp-sam']
resource url: [dir: 'images', file: 'subjectlayout.png', plugin: 'dbxp-sam'], attrs:[alt:''], disposition:'inline'
resource url: [dir: 'images', file: 'samplelayout.png', plugin: 'dbxp-sam'], attrs:[alt:''], disposition:'inline'
resource url: [dir: 'images', file: 'spinner.gif', plugin: 'dbxp-sam'], attrs:[alt:''], disposition:'inline'
Expand Down
Expand Up @@ -162,8 +162,13 @@ class MeasurementController {
ids.each { id ->
def measurementInstance = Measurement.get(id)
if (measurementInstance) {
def samSample = SAMSample.get(measurementInstance.sampleId)
try {
measurementInstance.delete(flush: true)
// If this was the last measurement in the SAMSample, delete it also
if (samSample.measurements.size() == 0) {
samSample.delete(flush: true)
}
numDeleted++;
} catch (org.springframework.dao.DataIntegrityViolationException e) {
log.error(e)
Expand Down
Expand Up @@ -43,6 +43,7 @@ class Measurement {
public static deleteByAssay( Assay a ) {
try {
Measurement.executeUpdate( "delete Measurement m WHERE m.sample IN( FROM SAMSample s where s.parentAssay = :assay )", [ assay: a ] );
SAMSample.executeUpdate("delete SAMSample s where s.parentAssay = :assay", [ assay: a ] )
return true;
} catch( Exception e ) {
e.printStackTrace();
Expand Down
13 changes: 4 additions & 9 deletions local-plugins/SAM/grails-app/views/SAMAssay/show.gsp
Expand Up @@ -10,6 +10,7 @@
.delete_button { display: none; }
td:hover .delete_button { display: inline; }
</style>
<r:require modules="tiptip" />
</head>
<body>
<content tag="contextmenu">
Expand Down Expand Up @@ -101,10 +102,7 @@
<g:if test="${isNumeric}">
<g:if test="${comments}">
<%-- numeric value and comments --%>
<div class="tooltip">
${cellMeasurements[0].value}
<span>${comments}</span>
</div>
<span class="tooltip" title="${comments}"> ${cellMeasurements[0].value}</span>
</g:if>
<g:else>
<g:if test="${cellMeasurements[0].value==cellMeasurements[0].value.round(3)}">
Expand All @@ -113,16 +111,13 @@
</g:if>
<g:else>
<%-- long numeric value without comments; render short version and put entire number in tooltip --%>
<span class="tooltip"> ${cellMeasurements[0].value.round(3).toString()}<span>${cellMeasurements[0].value}</span></span>
<span class="tooltip" title="${cellMeasurements[0].value}"> ${cellMeasurements[0].value.round(3).toString()}</span>
</g:else>
</g:else>
</g:if>
<g:else>
<%-- measurement is not numeric, so use text value from comments --%>
<div class="tooltip">
${comments}
<span>${comments}</span>
</div>
<span class="tooltip" title="${comments}">${comments}</span>
</g:else>
</td>
</g:if>
Expand Down
36 changes: 0 additions & 36 deletions local-plugins/SAM/web-app/css/tooltip.css

This file was deleted.

Expand Up @@ -222,7 +222,7 @@ class ImporterController {
numLinesImported: numLinesImported,

resultLink: importer.getLinkToResults(importInfo.parameter),

editLink: importer.getLinkToEdit(importInfo.parameter),
importInfo: importInfo
])
}
Expand Down
7 changes: 5 additions & 2 deletions local-plugins/dbxpBase/grails-app/views/importer/finish.gsp
Expand Up @@ -39,8 +39,11 @@
</g:else>
<p>
You can review your data at the following page: <g:link url="${resultLink.url}">${resultLink.label}</g:link> or
<g:link action="upload" params="${defaultParams + [importer:importInfo.importer]}">restart the importer</g:link>.
You can choose to: <g:link url="${resultLink.url}">${resultLink.label}</g:link>,
<g:if test="${editLink}">
<g:link url="${editLink.url}">${editLink.label}</g:link>
</g:if>
or <g:link action="upload" params="${defaultParams + [importer:importInfo.importer]}">restart the importer</g:link>.
</p>
Expand Down
Expand Up @@ -48,4 +48,11 @@ public abstract class AbstractImporter implements Importer {
* Returns whether the header options can only be selected for a single header.
*/
public boolean headerMappingIsUnique() { true }
}

/**
* Returns a link to the edit page
*/
public Map getLinkToEdit(def parameters) {
return null
}
}
12 changes: 9 additions & 3 deletions local-plugins/dbxpBase/src/groovy/dbnp/importer/Importer.groovy
Expand Up @@ -38,11 +38,17 @@ public interface Importer {
public List<ImportValidationError> getValidationErrors()

/**
* Returns a link to a page where results of the import can be seen.
* Returns a link to a page where results of the import can be seen.
* @return a map with two keys: url and label
*/
public Map getLinkToResults(def parameters)


/**
* Returns a link to a page where results of the import can be edited.
* @return a map with two keys: url and label
*/
public Map getLinkToEdit(def parameters)

/**
* Validates provided data.
* @param data Matrix (List of lists) with the data that has been loaded from the excel/csv file
Expand All @@ -65,4 +71,4 @@ public interface Importer {
* false if the validation on any of the object has failed
*/
public boolean importData(def data, def mapping, def parameters)
}
}
11 changes: 11 additions & 0 deletions scripts/_Events.groovy
Expand Up @@ -25,3 +25,14 @@ eventCompileEnd = {
ant.copy(file:"${basedir}/grails-app/conf/default.properties", todir:classesDirPath)
ant.echo (message: "Default configuration file moved.")
}

eventConfigureTomcat = { tomcat ->
println "Configuring tomcat max post size"

try {
tomcat.connector.maxPostSize = 1073741824
}
catch (Throwable t) {
println t
}
}

0 comments on commit b9fa9b4

Please sign in to comment.