summaryrefslogtreecommitdiffstats
path: root/idrop-web
diff options
context:
space:
mode:
authorMike Conway <mikeconway@dhcp152-54-6-70.wireless.europa.renci.org>2011-02-17 14:38:21 (GMT)
committer Mike Conway <mikeconway@dhcp152-54-6-70.wireless.europa.renci.org>2011-02-17 14:38:21 (GMT)
commita15b1277ccd81614e16bc162008f143a33a6c9ff (patch)
tree522610618401268ca10fc427ca0f8b7d83bb2b02 /idrop-web
parentd9704159770f7393245bc8020aa7386747255df1 (diff)
downloadQCG-Data-a15b1277ccd81614e16bc162008f143a33a6c9ff.zip
QCG-Data-a15b1277ccd81614e16bc162008f143a33a6c9ff.tar.gz
QCG-Data-a15b1277ccd81614e16bc162008f143a33a6c9ff.tar.bz2
add tag cloud to web view
Diffstat (limited to 'idrop-web')
-rw-r--r--idrop-web/application.properties11
-rw-r--r--idrop-web/grails-app/conf/Config.groovy2
-rw-r--r--idrop-web/grails-app/conf/spring/resources.groovy5
-rw-r--r--idrop-web/grails-app/controllers/org/irods/mydrop/controller/BrowseController.groovy57
-rw-r--r--idrop-web/grails-app/controllers/org/irods/mydrop/controller/TagsController.groovy37
-rw-r--r--idrop-web/grails-app/taglib/AuthTagLib.groovy26
-rw-r--r--idrop-web/grails-app/views/browse/collectionInfo.gsp18
-rw-r--r--idrop-web/grails-app/views/common/_secondarymain.gsp12
-rw-r--r--idrop-web/grails-app/views/layouts/main.gsp2
-rw-r--r--idrop-web/grails-app/views/tags/tagCloud.gsp5
-rw-r--r--idrop-web/test/unit/org/irods/mydrop/controller/BrowseControllerTests.groovy32
-rw-r--r--idrop-web/test/unit/org/irods/mydrop/controller/TagsControllerTests.groovy62
-rw-r--r--idrop-web/test/unit/org/irods/mydrop/taglib/AuthTagLibTests.groovy17
13 files changed, 237 insertions, 49 deletions
diff --git a/idrop-web/application.properties b/idrop-web/application.properties
index 6dc2b25..4f0f2d3 100644
--- a/idrop-web/application.properties
+++ b/idrop-web/application.properties
@@ -1,8 +1,9 @@
#Grails Metadata file
-#Mon Dec 13 18:50:00 EST 2010
-app.grails.version=1.3.6
-app.name=idrop-web
-app.servlet.version=2.4
+#Wed Feb 16 18:41:31 EST 2011
app.version=0.9.1-SNAPSHOT
-plugins.hibernate=1.3.5
+plugins.acegi=0.5.3.2
+app.servlet.version=2.4
+app.grails.version=1.3.6
plugins.tomcat=1.3.5
+plugins.hibernate=1.3.5
+app.name=idrop-web
diff --git a/idrop-web/grails-app/conf/Config.groovy b/idrop-web/grails-app/conf/Config.groovy
index 21a0162..07473a0 100644
--- a/idrop-web/grails-app/conf/Config.groovy
+++ b/idrop-web/grails-app/conf/Config.groovy
@@ -67,7 +67,7 @@ environments {
log4j = {
root {
- warn()
+ info()
additivity = true
}
diff --git a/idrop-web/grails-app/conf/spring/resources.groovy b/idrop-web/grails-app/conf/spring/resources.groovy
index 94d1ac8..d8f633e 100644
--- a/idrop-web/grails-app/conf/spring/resources.groovy
+++ b/idrop-web/grails-app/conf/spring/resources.groovy
@@ -6,4 +6,9 @@ beans = {
taggingServiceFactory = ref("taggingServiceFactory")
}
+ tagsController(org.irods.mydrop.controller.TagsController) {
+ irodsAccessObjectFactory = ref("irodsAccessObjectFactory")
+ taggingServiceFactory = ref("taggingServiceFactory")
+ }
+
}
diff --git a/idrop-web/grails-app/controllers/org/irods/mydrop/controller/BrowseController.groovy b/idrop-web/grails-app/controllers/org/irods/mydrop/controller/BrowseController.groovy
index b9d9dca..8be653d 100644
--- a/idrop-web/grails-app/controllers/org/irods/mydrop/controller/BrowseController.groovy
+++ b/idrop-web/grails-app/controllers/org/irods/mydrop/controller/BrowseController.groovy
@@ -17,39 +17,39 @@ import org.springframework.security.core.context.SecurityContextHolder
*/
class BrowseController {
-
+
IRODSAccessObjectFactory irodsAccessObjectFactory
TaggingServiceFactory taggingServiceFactory
IRODSAccount irodsAccount
-
+
/**
* Interceptor grabs IRODSAccount from the SecurityContextHolder
*/
def beforeInterceptor = {
def irodsAuthentication = SecurityContextHolder.getContext().authentication
-
+
if (irodsAuthentication == null) {
throw new JargonRuntimeException("no irodsAuthentication in security context!")
}
-
+
irodsAccount = irodsAuthentication.irodsAccount
log.debug("retrieved account for request: ${irodsAccount}")
}
-
-
+
+
/**
* Display initial browser
*/
def index = { }
-
-
+
+
/**
* Render the tree node data for the given parent. This will use the HTML style AJAX response to depict the children using unordered lists.
* <p/>
* Requires param 'dir' from request to derive parent
*
*/
- def loadTree = {
+ def loadTree = {
def parent = params['dir']
log.info "loading tree for parent path: ${parent}"
def collectionAndDataObjectListAndSearchAO = irodsAccessObjectFactory.getCollectionAndDataObjectListAndSearchAO(irodsAccount)
@@ -58,18 +58,18 @@ class BrowseController {
//render(view:"loadTree",model:[collectionAndDataObjectList:collectionAndDataObjectList, parent:parent])
render collectionAndDataObjectList as JSON
}
-
+
def ajaxDirectoryListingUnderParent = {
def parent = params['dir']
log.info "ajaxDirectoryListingUnderParent path: ${parent}"
def collectionAndDataObjectListAndSearchAO = irodsAccessObjectFactory.getCollectionAndDataObjectListAndSearchAO(irodsAccount)
def collectionAndDataObjectList = collectionAndDataObjectListAndSearchAO.listDataObjectsAndCollectionsUnderPath(parent)
log.debug("retrieved collectionAndDataObjectList: ${collectionAndDataObjectList}")
-
+
def jsonBuff = []
-
- collectionAndDataObjectList.each {
-
+
+ collectionAndDataObjectList.each {
+
def icon
def state
def type
@@ -82,45 +82,44 @@ class BrowseController {
state = "closed"
type = "folder"
}
-
+
def attrBuf = ["id":it.formattedAbsolutePath, "rel":type]
-
+
jsonBuff.add(
["data": it.nodeLabelDisplayValue,"attr":attrBuf, "state":state,"icon":icon, "type":type]
)
-
}
-
+
render jsonBuff as JSON
}
-
+
def fileInfo = {
def absPath = params['absPath']
if (absPath == null) {
throw new JargonException("no absolute path passed to the method")
-
}
-
+
log.info "fileInfo for absPath: ${absPath}"
CollectionAndDataObjectListAndSearchAO collectionAndDataObjectListAndSearchAO = irodsAccessObjectFactory.getCollectionAndDataObjectListAndSearchAO(irodsAccount)
-
+
// TODO: some sort of catch and display of no data available in info?
def retObj = collectionAndDataObjectListAndSearchAO.getFullObjectForType(absPath)
-
+
def isDataObject = retObj instanceof DataObject
-
+
log.info "is this a data object? ${isDataObject}"
-
+
FreeTaggingService freeTaggingService = taggingServiceFactory.instanceFreeTaggingService(irodsAccount)
if (isDataObject) {
log.info("getting free tags for data object")
def freeTags = freeTaggingService.getTagsForDataObjectInFreeTagForm(absPath)
log.info("rendering as data object: ${retObj}")
render(view:"dataObjectInfo", model:[dataObject:retObj,tags:freeTags])
+ } else {
+ log.info("getting free tags for collection")
+ def freeTags = freeTaggingService.getTagsForCollectionInFreeTagForm(absPath)
+ log.info("rendering as collection: ${retObj}")
+ render(view:"collectionInfo", model:[collection:retObj,tags:freeTags])
}
-
}
-
-
-
}
diff --git a/idrop-web/grails-app/controllers/org/irods/mydrop/controller/TagsController.groovy b/idrop-web/grails-app/controllers/org/irods/mydrop/controller/TagsController.groovy
index 7550c23..d1e13fc 100644
--- a/idrop-web/grails-app/controllers/org/irods/mydrop/controller/TagsController.groovy
+++ b/idrop-web/grails-app/controllers/org/irods/mydrop/controller/TagsController.groovy
@@ -1,9 +1,44 @@
package org.irods.mydrop.controller
+import org.irods.jargon.core.connection.IRODSAccount
+import org.irods.jargon.core.exception.JargonRuntimeException
+import org.irods.jargon.core.pub.IRODSAccessObjectFactory
+import org.irods.jargon.usertagging.TaggingServiceFactory
+import org.irods.jargon.usertagging.UserTagCloudService
+import org.irods.jargon.usertagging.domain.UserTagCloudView
+import org.springframework.security.core.context.SecurityContextHolder
+
class TagsController {
+
+ IRODSAccessObjectFactory irodsAccessObjectFactory
+ TaggingServiceFactory taggingServiceFactory
+ IRODSAccount irodsAccount
+
+ /**
+ * Interceptor grabs IRODSAccount from the SecurityContextHolder
+ */
+ def beforeInterceptor = {
+ def irodsAuthentication = SecurityContextHolder.getContext().authentication
+
+ if (irodsAuthentication == null) {
+ throw new JargonRuntimeException("no irodsAuthentication in security context!")
+ }
+
+ irodsAccount = irodsAuthentication.irodsAccount
+ log.debug("retrieved account for request: ${irodsAccount}")
+ }
+
def index = { }
- def tagCloud = {}
+ def tagCloud = {
+
+ log.info("getting tag cloud for user: ${irodsAccount}")
+ UserTagCloudService userTagCloudService = taggingServiceFactory.instanceUserTagCloudService(irodsAccount)
+ UserTagCloudView userTagCloudView = userTagCloudService.getTagCloud()
+ def entries = userTagCloudView.getTagCloudEntries().values()
+ render(view:"tagCloud", model:[tagCloud:entries])
+
+ }
}
diff --git a/idrop-web/grails-app/taglib/AuthTagLib.groovy b/idrop-web/grails-app/taglib/AuthTagLib.groovy
new file mode 100644
index 0000000..fee2283
--- /dev/null
+++ b/idrop-web/grails-app/taglib/AuthTagLib.groovy
@@ -0,0 +1,26 @@
+
+import org.springframework.security.core.context.SecurityContextHolder
+
+class AuthTagLib {
+
+ private boolean isAuthenticated() {
+ //auth = session.SPRING_SECURITY_CONTEXT?.authentication?.authenticated
+ def auth = session["SPRING_SECURITY_CONTEXT"]
+ //log.info("auth is: ${auth}")
+ return auth != null
+ }
+
+
+ def ifAuthenticated = { attrs, body ->
+ if (isAuthenticated()) {
+ out << body()
+ }
+ }
+
+ def ifNotAuthenticated = { attrs, body ->
+ if (!isAuthenticated()) {
+ out << body()
+ }
+ }
+
+}
diff --git a/idrop-web/grails-app/views/browse/collectionInfo.gsp b/idrop-web/grails-app/views/browse/collectionInfo.gsp
new file mode 100644
index 0000000..9656a5c
--- /dev/null
+++ b/idrop-web/grails-app/views/browse/collectionInfo.gsp
@@ -0,0 +1,18 @@
+<fieldset id="verticalForm">
+
+<label for="">Parent
+Collection:</label> <g:textField name="collectionParentName"
+ value="${collection.collectionParentName}" readonly="true" /> <br />
+
+<label for="collectionName">Collection Name:</label> <g:textField name="collectionName"
+ value="${collection.collectionName}" readonly="true" /> <br />
+
+<label for="createdAt">Created At:</label> <g:textField name="createdAt"
+ value="${collection.createdAt}" readonly="true" /> <br />
+
+<label for="tags">Tags:</label> <g:textField name="tags"
+ value="${tags.spaceDelimitedTagsForDomain}" /> <br />
+
+
+
+</fieldset> \ No newline at end of file
diff --git a/idrop-web/grails-app/views/common/_secondarymain.gsp b/idrop-web/grails-app/views/common/_secondarymain.gsp
index c85470c..9eee188 100644
--- a/idrop-web/grails-app/views/common/_secondarymain.gsp
+++ b/idrop-web/grails-app/views/common/_secondarymain.gsp
@@ -1,6 +1,8 @@
<script>
$(function() {
$("#secondaryTabs").tabs();
+ lcSendValueAndCallbackHtmlAfterErrorCheck("/tags/tagCloud", "#tagCloudDiv",
+ "#tagCloudDiv", null);
});
</script>
<div id="secondaryTabs">
@@ -10,11 +12,11 @@
</ul>
<div id="tabs-1">
-<ul>
- <li>tag1</li>
- <li>tag2</li>
- <li>tag3</li>
-</ul>
+<div id="tagCloudDiv" class="scroll">
+
+<!-- tag cloud div is ajax loaded -->
+
+</div>
</div>
<div id="tabs-2">
<ul>
diff --git a/idrop-web/grails-app/views/layouts/main.gsp b/idrop-web/grails-app/views/layouts/main.gsp
index bb825a2..9dcc726 100644
--- a/idrop-web/grails-app/views/layouts/main.gsp
+++ b/idrop-web/grails-app/views/layouts/main.gsp
@@ -37,7 +37,9 @@
<g:layoutBody />
</div>
<div class="yui-u"><!-- PUT MAIN COLUMN 2 CODE HERE -->
+<g:ifAuthenticated>
<g:render template="/common/secondarymain"/>
+</g:ifAuthenticated>
</div>
</div>
diff --git a/idrop-web/grails-app/views/tags/tagCloud.gsp b/idrop-web/grails-app/views/tags/tagCloud.gsp
new file mode 100644
index 0000000..9bc96d5
--- /dev/null
+++ b/idrop-web/grails-app/views/tags/tagCloud.gsp
@@ -0,0 +1,5 @@
+<ul>
+<g:each in="${tagCloud}" var="tagVal">
+ <li>${tagVal.irodsTagValue.tagData}</li>
+</g:each>
+</ul> \ No newline at end of file
diff --git a/idrop-web/test/unit/org/irods/mydrop/controller/BrowseControllerTests.groovy b/idrop-web/test/unit/org/irods/mydrop/controller/BrowseControllerTests.groovy
index 695e818..5aab305 100644
--- a/idrop-web/test/unit/org/irods/mydrop/controller/BrowseControllerTests.groovy
+++ b/idrop-web/test/unit/org/irods/mydrop/controller/BrowseControllerTests.groovy
@@ -12,6 +12,7 @@ import org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO
import org.irods.jargon.core.pub.IRODSAccessObjectFactory
import org.irods.jargon.core.pub.IRODSFileSystem
import org.irods.jargon.core.pub.domain.DataObject
+import org.irods.jargon.core.pub.domain.Collection
import org.irods.jargon.core.query.MetaDataAndDomainData
import org.irods.jargon.spring.security.IRODSAuthenticationToken
import org.irods.jargon.testutils.TestingPropertiesHelper
@@ -102,4 +103,35 @@ class BrowseControllerTests extends ControllerUnitTestCase {
}
+ void testFileInfoWithPathWhenCollection() {
+ def testPath = "/testpath"
+ def irodsAccessObjectFactory = Mockito.mock(IRODSAccessObjectFactory.class)
+ CollectionAndDataObjectListAndSearchAO collectionListAndSearchAO = Mockito.mock(CollectionAndDataObjectListAndSearchAO.class)
+ Collection retObject = new Collection()
+ retObject.setCollectionName(testPath)
+ Mockito.when(collectionListAndSearchAO.getFullObjectForType(testPath)).thenReturn(retObject)
+ Mockito.when(irodsAccessObjectFactory.getCollectionAndDataObjectListAndSearchAO(irodsAccount)).thenReturn(collectionListAndSearchAO)
+ controller.irodsAccessObjectFactory = irodsAccessObjectFactory
+ FreeTaggingService freeTaggingService = Mockito.mock(FreeTaggingService.class)
+ TaggingServiceFactory taggingServiceFactory = Mockito.mock(TaggingServiceFactory.class)
+ IRODSTagGrouping grouping = new IRODSTagGrouping(MetaDataAndDomainData.MetadataDomain.COLLECTION, "name", "tags", "user")
+ Mockito.when(freeTaggingService.getTagsForCollectionInFreeTagForm(testPath)).thenReturn(grouping)
+ Mockito.when(taggingServiceFactory.instanceFreeTaggingService(irodsAccount)).thenReturn(freeTaggingService)
+ controller.irodsAccount = irodsAccount
+ controller.taggingServiceFactory = taggingServiceFactory
+ controller.params.absPath = testPath
+ controller.fileInfo()
+ def mav = controller.modelAndView
+ def name = mav.viewName
+
+ assertNotNull("null mav", mav)
+ assertEquals("view name should be collectionInfo", "collectionInfo", name)
+ def collection = mav.model.collection
+ assertNotNull("null collection object", collection)
+ assertEquals("did not find expected path", testPath, collection.collectionName)
+ def tags = mav.model.tags
+ assertNotNull("null tag in model", tags)
+
+ }
+
}
diff --git a/idrop-web/test/unit/org/irods/mydrop/controller/TagsControllerTests.groovy b/idrop-web/test/unit/org/irods/mydrop/controller/TagsControllerTests.groovy
index f3a8063..ed2f326 100644
--- a/idrop-web/test/unit/org/irods/mydrop/controller/TagsControllerTests.groovy
+++ b/idrop-web/test/unit/org/irods/mydrop/controller/TagsControllerTests.groovy
@@ -1,18 +1,64 @@
+
package org.irods.mydrop.controller
+import java.util.Properties;
+
+import grails.converters.*
import grails.test.*
+import org.irods.jargon.core.connection.IRODSAccount
+import org.irods.jargon.core.pub.IRODSAccessObjectFactory
+import org.irods.jargon.core.pub.IRODSFileSystem
+import org.irods.jargon.testutils.TestingPropertiesHelper
+import org.irods.jargon.usertagging.UserTagCloudService
+import org.irods.jargon.usertagging.domain.UserTagCloudView
+import org.irods.jargon.usertagging.domain.IRODSTagValue
+import org.irods.jargon.usertagging.TaggingServiceFactory
+import org.irods.jargon.spring.security.IRODSAuthenticationToken
+import org.springframework.security.core.context.SecurityContextHolder
+import org.mockito.Mockito
+
+
class TagsControllerTests extends ControllerUnitTestCase {
- protected void setUp() {
- super.setUp()
- }
+
+ IRODSAccessObjectFactory irodsAccessObjectFactory
+ IRODSAccount irodsAccount
+ Properties testingProperties
+ TestingPropertiesHelper testingPropertiesHelper
+ IRODSFileSystem irodsFileSystem
- protected void tearDown() {
- super.tearDown()
- }
+ protected void setUp() {
+ super.setUp()
+ testingPropertiesHelper = new TestingPropertiesHelper()
+ testingProperties = testingPropertiesHelper.getTestProperties()
+ irodsAccount = testingPropertiesHelper.buildIRODSAccountFromTestProperties(testingProperties)
+ irodsFileSystem = IRODSFileSystem.instance()
+ irodsAccessObjectFactory = irodsFileSystem.getIRODSAccessObjectFactory()
+ def irodsAuthentication = new IRODSAuthenticationToken(irodsAccount)
+ SecurityContextHolder.getContext().authentication = irodsAuthentication
+ }
- void testSomething() {
+ protected void tearDown() {
+ super.tearDown()
+ }
- }
+ void testGetTagCloud() {
+ controller.irodsAccessObjectFactory = irodsAccessObjectFactory
+ UserTagCloudService userTagCloudService = Mockito.mock(UserTagCloudService.class)
+ TaggingServiceFactory taggingServiceFactory = Mockito.mock(TaggingServiceFactory.class)
+ UserTagCloudView userTagCloudView = UserTagCloudView.instance(irodsAccount.getUserName(), new ArrayList<IRODSTagValue>(), new ArrayList<IRODSTagValue>())
+ Mockito.when(userTagCloudService.getTagCloud()).thenReturn(userTagCloudView)
+ Mockito.when(taggingServiceFactory.instanceUserTagCloudService(irodsAccount)).thenReturn(userTagCloudService)
+ controller.irodsAccount = irodsAccount
+ controller.taggingServiceFactory = taggingServiceFactory
+ controller.tagCloud()
+ def mav = controller.modelAndView
+ def name = mav.viewName
+ assertNotNull("null mav", mav)
+ assertEquals("view name should be tagCloud", "tagCloud", name)
+ def tagView = mav.model.tagCloud
+ assertNotNull("null tagView in model", tagView)
+
+ }
}
diff --git a/idrop-web/test/unit/org/irods/mydrop/taglib/AuthTagLibTests.groovy b/idrop-web/test/unit/org/irods/mydrop/taglib/AuthTagLibTests.groovy
new file mode 100644
index 0000000..479b6e9
--- /dev/null
+++ b/idrop-web/test/unit/org/irods/mydrop/taglib/AuthTagLibTests.groovy
@@ -0,0 +1,17 @@
+package org.irods.mydrop.taglib
+
+import grails.test.*
+
+class AuthTagLibTests extends TagLibUnitTestCase {
+ protected void setUp() {
+ super.setUp()
+ }
+
+ protected void tearDown() {
+ super.tearDown()
+ }
+
+ void testSomething() {
+
+ }
+}