Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project collections #17

Closed
wants to merge 62 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
87e7e06
Syncing the latest models from test.
chrisala Nov 24, 2014
4c8ef2a
Syncing the latest models from test.
chrisala Nov 24, 2014
2e87e87
Fixed an indexing issue, now both active and completed status are ind…
sat01a Nov 26, 2014
02123f1
Merge pull request #2 from sat01a/master
sat01a Nov 26, 2014
9e31fc6
Synced activity model from test.
chrisala Nov 27, 2014
14961a8
Homepage carousel functionality
sat01a Dec 2, 2014
a0ed4fc
Addressed review comments
sat01a Dec 2, 2014
2a5eb4f
Added an explicit mapping for the MERI plan budget field.
chrisala Dec 2, 2014
9ba99f5
Merge branch 'master' of https://github.com/AtlasOfLivingAustralia/ec…
sat01a Dec 2, 2014
f15bf70
Merge pull request #4 from sat01a/master
sat01a Dec 2, 2014
476a538
Allow promoteOnHomepage to be nullable to support existing data.
chrisala Dec 3, 2014
2e5cfbe
Updated data models for small grants
Oct 8, 2014
4a90373
Updated data models for small grants
Oct 8, 2014
c1a4487
Updated data models for small grants
Dec 4, 2014
209d0e5
Added custom mapping to ES.
sat01a Dec 4, 2014
bb0ac5a
Merge pull request #5 from sat01a/master
chrisala Dec 4, 2014
c48ba50
Updated data models for small grants
Dec 5, 2014
3cfdd59
Descriptions added to attributes
Dec 5, 2014
086d58c
maven repo update: maven.ala.org.au => nexus.ala.org.au
mbohun Dec 8, 2014
1eaccad
Made numberPlanted field mandatory
Jan 5, 2015
aee8430
New green army data models.
Jan 15, 2015
93843d8
Remove unnecessary fields
Jan 15, 2015
b4c5ba7
sync with ala-web-theme:1.1.0 and ala-auth:1.0.0
Jan 29, 2015
c42dfbe
use bootstrap resource defs from ala-web-theme plugin
Feb 2, 2015
26dd465
use nci-auth instead of auth for CAS
Feb 3, 2015
131ecc6
Merge branch 'project_collections' of https://github.com/AtlasOfLivin…
Feb 4, 2015
a2678d5
use config from ala-auth-plugin
Feb 4, 2015
9e28522
use ala-auth
jamirali Feb 4, 2015
8037241
Merge branch 'project_collections' of https://github.com/jamirali/eco…
jamirali Feb 4, 2015
500539f
use ala-bootstrap2 plugin
jamirali Feb 5, 2015
1346886
define app_bootstrap et alia
jamirali Feb 5, 2015
1cfac15
use 1.0-SNAPSHOT of ala-auth
jamirali Feb 6, 2015
8bca871
Merge branch 'project_collections'
chrisala Feb 9, 2015
46c44bf
Merge branch 'project_collections'
chrisala Feb 9, 2015
4395d46
Switched the build over to the ALA nexus repository.
chrisala Feb 10, 2015
9c32414
Merge https://github.com/AtlasOfLivingAustralia/ecodata into project_…
jamirali Feb 10, 2015
b5ae756
Model sync.
chrisala Feb 11, 2015
6181581
Merged branch to master.
chrisala Feb 11, 2015
5a50c59
Merge pull request #20 from chrisala/master
chrisala Feb 11, 2015
fb83739
Removed the auth call that returns the full user list.
chrisala Feb 11, 2015
c8c88c5
Merge pull request #21 from chrisala/master
chrisala Feb 11, 2015
e630ffa
Syncing fieldcapture-dev models with git.
sat01a Feb 11, 2015
3ef6780
Merge pull request #22 from sat01a/master
sat01a Feb 11, 2015
43078c1
Updated the ehcache plugin to allow a cache name to be specified.
chrisala Feb 12, 2015
86e64ac
Merge pull request #23 from chrisala/master
chrisala Feb 12, 2015
dcefc85
Removed a println.
chrisala Feb 12, 2015
348b551
Merge pull request #24 from chrisala/master
sat01a Feb 12, 2015
f9a402f
Dealing with the pain of a case change.
chrisala Feb 12, 2015
f475698
Merge remote-tracking branch 'upstream/master'
chrisala Feb 12, 2015
ff53018
Organisation reporting bulk download and upload functionality
sat01a Feb 12, 2015
bf58005
Including abandoned state.
sat01a Feb 12, 2015
74896c0
Merge pull request #25 from sat01a/master
chrisala Feb 12, 2015
518241f
Merge remote-tracking branch 'upstream/master'
chrisala Feb 13, 2015
2e80c94
fix auth link; add attrs to Project
jamirali Feb 13, 2015
e6cac37
use ala-auth/ala-bootstrap2 instead of ala-web-theme
jamirali Feb 13, 2015
48f8eb4
Merge https://github.com/AtlasOfLivingAustralia/ecodata into project_…
jamirali Feb 16, 2015
4320f9d
Added service provider fields to the project entity.
chrisala Feb 16, 2015
bedac89
fixed security.apikey.serviceUrl
jamirali Feb 16, 2015
d948dc7
Allow the view type to be passed to the project search.
chrisala Feb 17, 2015
7a821ec
Merge pull request #26 from chrisala/master
sat01a Feb 17, 2015
d42dae4
Merge https://github.com/AtlasOfLivingAustralia/ecodata into project_…
jamirali Feb 17, 2015
97a01bf
use ala-auth:1.0
jamirali Feb 18, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Organisation reporting bulk download and upload functionality
  • Loading branch information
sat01a committed Feb 12, 2015
commit ff5301871ec6d4937c92101952ce540a88cfdfb6
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import grails.converters.JSON

class MetadataController {

def metadataService, cacheService
def metadataService, activityService, commonService, projectService

def activitiesModel() {
render metadataService.activitiesModel()
Expand Down Expand Up @@ -127,6 +127,54 @@ class MetadataController {

}

/**
* Returns an Excel template with data that can be populated and uploaded.
*/
def excelBulkActivityTemplate() {
def props = request.JSON
def activityType = props?.type
List activityIds = props?.ids?.split(',')

if (!activityType || !activityIds) {
def result = [status:400, error:'type and ids are required']
render result as JSON
return null
}

def activityModel = metadataService.activitiesModel().activities.find { it.name == activityType }
def outputModels = activityModel.outputs?.collect {
[name:it, annotatedModel:metadataService.annotatedOutputDataModel(it), dataModel:metadataService.getDataModelFromOutputName(it)]
}

def activities = activityIds?.collect{act-> activityService.getAll(activityIds).find{it.activityId == act}}
def outputData = []
activities?.each { val ->
def project = projectService.get(val.projectId)
def data = [projectName: project.name,grantId:project.grantId]
if(val.outputs?.size() > 0) {
val.outputs?.each{ content ->
if(!"abandoned".equalsIgnoreCase(content.data?.projectStatus)){
outputData.add( data << content.data)
}
}
}
else {
outputData.add(data)
}
}

def model = [[name:"projectName", label:"Project Name",dataType:"text",description:"Project Description",rowHeader:true],
[name:"grantId", label:"Project",dataType:"text",description:"Grant Id",rowHeader:true]]
outputModels?.first().annotatedModel.collect { model.add(it) }

def outputName = "${outputModels?.first().name}"
OutputUploadTemplateBuilder builder = new OutputUploadTemplateBuilder(outputName, model, outputData)
builder.build()
builder.setResponseHeaders(response)
builder.save(response.outputStream)
return null
}

def getLocationMetadataForPoint(double lat, double lng) {
render metadataService.getLocationMetadataForPoint(lat, lng) as JSON
}
Expand Down
9 changes: 9 additions & 0 deletions grails-app/services/au/org/ala/ecodata/MetadataService.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ class MetadataService {
return activitiesModel().outputs.find { it.name == name }
}

def getDataModelFromOutputName(outputName) {
def activityName = getActivityModelName(outputName)
return activityName ?: getOutputDataModel(activityName)
}

def getActivityModelName(outputName) {
return activitiesModel().outputs.find({it.name == outputName})?.template
}

def getOutputDataModel(templateName) {
return cacheService.get(templateName + '-model',{
String filename = (grailsApplication.config.app.external.model.dir as String) + templateName + '/dataModel.json'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,22 @@ class OutputUploadTemplateBuilder extends XlsExporter {

def model
def outputName
def data

public OutputUploadTemplateBuilder(outputName, model) {
super(outputName)
this.outputName = outputName
this.model = model.findAll{!it.computed}
}

public OutputUploadTemplateBuilder(outputName, model, data) {
super(outputName)
this.outputName = outputName
this.model = model.findAll{!it.computed}
this.data = data
}


public void build() {

def headers = model.collect {
Expand All @@ -29,6 +38,9 @@ class OutputUploadTemplateBuilder extends XlsExporter {
AdditionalSheet outputSheet = addSheet(outputName, headers)

new ValidationProcessor(getWorkbook(), outputSheet.sheet, model).process()

new OutputDataProcessor(getWorkbook(), outputSheet.sheet, model, data, getStyle()).process()

finalise()
}

Expand All @@ -38,6 +50,59 @@ class OutputUploadTemplateBuilder extends XlsExporter {

}

class OutputDataProcessor {
private Workbook workbook
private Sheet sheet
def model
def data
def rowHeaderStyle

public OutputDataProcessor(workbook, sheet, model, data, rowHeaderStyle){
this.workbook = workbook
this.sheet = sheet
this.model = model
this.data = data
this.rowHeaderStyle = rowHeaderStyle
}

public void process() {

data?.eachWithIndex { rowValue, rowCount ->
Row row = sheet.createRow((rowCount+1))

for(int i = 0; i < rowValue.size(); i++){
def dataType, value, rowHeader
model.eachWithIndex { modelVal, modelIndex ->
if(modelIndex == i) {
rowValue?.each{key, val ->
if(key.equals(modelVal.name)){
value = val
dataType = modelVal.dataType
rowHeader = modelVal.rowHeader
}
}
}
}
if(dataType) {
Cell cell = row.createCell(i)
switch(dataType){
case 'number':
cell.setCellValue(value.toInteger())
break
case 'date':
case 'text':
default:
cell.setCellValue(value.toString())
break
}
if(rowHeader){
cell.setCellStyle(rowHeaderStyle);
}
}
}
}
}
}

class ValidationProcessor extends OutputModelProcessor {

Expand Down
4 changes: 4 additions & 0 deletions src/groovy/au/org/ala/ecodata/reporting/XlsExporter.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ class XlsExporter extends WebXlsxExporter {
return headerStyle
}

def getStyle(){
headerStyle(getWorkbook())
}

WebXlsxExporter setResponseHeaders(HttpServletResponse response) {
super.setResponseHeaders(response, fileName+filenameSuffix)
this
Expand Down