-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
44 changed files
with
4,735 additions
and
1,696 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
grails-app/services/org/bbop/apollo/AvailableStatusService.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.bbop.apollo | ||
|
||
import grails.transaction.Transactional | ||
import org.codehaus.groovy.grails.web.json.JSONArray | ||
|
||
@Transactional | ||
class AvailableStatusService { | ||
|
||
JSONArray getAvailableStatuses(Organism organism, List<FeatureType> featureTypeList) { | ||
JSONArray availableStatusesJSONArray = new JSONArray(); | ||
// add all CC with no type and organism | ||
List<AvailableStatus> availableStatusList = new ArrayList<>() | ||
if (featureTypeList) { | ||
availableStatusList.addAll(AvailableStatus.executeQuery("select cc from AvailableStatus cc join cc.featureTypes ft where ft in (:featureTypeList)", [featureTypeList: featureTypeList])) | ||
} | ||
availableStatusList.addAll(AvailableStatus.executeQuery("select cc from AvailableStatus cc where cc.featureTypes is empty")) | ||
|
||
// if there are organism filters for these canned comments for this organism, then apply them | ||
List<AvailableStatusOrganismFilter> availableStatusOrganismFilters = AvailableStatusOrganismFilter.findAllByAvailableStatusInList(availableStatusList) | ||
if (availableStatusOrganismFilters) { | ||
// if the organism is in the list, that is good | ||
AvailableStatusOrganismFilter.findAllByOrganismAndAvailableStatusInList(organism, availableStatusList).each { | ||
availableStatusesJSONArray.put(it.availableStatus.value) | ||
} | ||
// we have to add anything from availableStatusList that isn't in another one | ||
List<AvailableStatus> availableStatusesToExclude = AvailableStatusOrganismFilter.findAllByOrganismNotEqualAndAvailableStatusInList(organism, availableStatusList).availableStatus | ||
for(AvailableStatus availableStatus in availableStatusList){ | ||
if(!availableStatusesJSONArray.contains(availableStatus.value) && !availableStatusesToExclude.contains(availableStatus)){ | ||
availableStatusesJSONArray.put(availableStatus.value) | ||
} | ||
} | ||
} | ||
// otherwise ignore them | ||
else { | ||
availableStatusList.each { | ||
availableStatusesJSONArray.put(it.value) | ||
} | ||
} | ||
return availableStatusesJSONArray | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
grails-app/services/org/bbop/apollo/CannedAttributeService.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package org.bbop.apollo | ||
|
||
import grails.transaction.Transactional | ||
import org.codehaus.groovy.grails.web.json.JSONArray | ||
|
||
@Transactional | ||
class CannedAttributeService { | ||
|
||
JSONArray getCannedKeys(Organism organism, List<FeatureType> featureTypeList) { | ||
JSONArray cannedKeysJSONArray = new JSONArray(); | ||
List<CannedKey> cannedKeyList = new ArrayList<>() | ||
if (featureTypeList) { | ||
cannedKeyList.addAll(CannedKey.executeQuery("select cc from CannedKey cc join cc.featureTypes ft where ft in (:featureTypeList)", [featureTypeList: featureTypeList])) | ||
} | ||
cannedKeyList.addAll(CannedKey.executeQuery("select cc from CannedKey cc where cc.featureTypes is empty")) | ||
|
||
// if there are organism filters for these canned comments for this organism, then apply them | ||
List<CannedKeyOrganismFilter> cannedKeyOrganismFilters = CannedKeyOrganismFilter.findAllByCannedKeyInList(cannedKeyList) | ||
if (cannedKeyOrganismFilters) { | ||
CannedKeyOrganismFilter.findAllByOrganismAndCannedKeyInList(organism, cannedKeyList).each { | ||
cannedKeysJSONArray.put(it.cannedKey.label) | ||
} | ||
// we have to add anything from cannedCommentList that isn't in another one | ||
List<CannedKey> cannedKeysToExclude = CannedKeyOrganismFilter.findAllByOrganismNotEqualAndCannedKeyInList(organism, cannedKeyList).cannedKey | ||
for(CannedKey cannedKey in cannedKeyList){ | ||
if(!cannedKeysJSONArray.contains(cannedKey.label) && !cannedKeysToExclude.contains(cannedKey)){ | ||
cannedKeysJSONArray.put(cannedKey.label) | ||
} | ||
} | ||
} | ||
// otherwise ignore them | ||
else { | ||
cannedKeyList.each { | ||
cannedKeysJSONArray.put(it.label) | ||
} | ||
} | ||
return cannedKeysJSONArray | ||
} | ||
|
||
JSONArray getCannedValues(Organism organism, List<FeatureType> featureTypeList) { | ||
|
||
JSONArray cannedValuesJSONArray = new JSONArray(); | ||
|
||
List<CannedValue> cannedValueList = new ArrayList<>() | ||
if (featureTypeList) { | ||
cannedValueList.addAll(CannedValue.executeQuery("select cc from CannedValue cc join cc.featureTypes ft where ft in (:featureTypeList)", [featureTypeList: featureTypeList])) | ||
} | ||
cannedValueList.addAll(CannedValue.executeQuery("select cc from CannedValue cc where cc.featureTypes is empty")) | ||
|
||
// if there are organism filters for these canned comments for this organism, then apply them | ||
List<CannedValueOrganismFilter> cannedValueOrganismFilters = CannedValueOrganismFilter.findAllByCannedValueInList(cannedValueList) | ||
if (cannedValueOrganismFilters) { | ||
CannedValueOrganismFilter.findAllByOrganismAndCannedValueInList(organism, cannedValueList).each { | ||
cannedValuesJSONArray.put(it.cannedValue.label) | ||
} | ||
// we have to add anything from cannedValueList that isn't in another one | ||
List<CannedValue> cannedValuesToExclude = CannedValueOrganismFilter.findAllByOrganismNotEqualAndCannedValueInList(organism, cannedValueList).cannedValue | ||
for(CannedValue cannedValue in cannedValueList){ | ||
if(!cannedValuesJSONArray.contains(cannedValue.label) && !cannedValuesToExclude.contains(cannedValue)){ | ||
cannedValuesJSONArray.put(cannedValue.label) | ||
} | ||
} | ||
} | ||
// otherwise ignore them | ||
else { | ||
cannedValueList.each { | ||
cannedValuesJSONArray.put(it.label) | ||
} | ||
} | ||
return cannedValuesJSONArray | ||
} | ||
} |
Oops, something went wrong.