Current Users (by group)
Flash plugin or Javascript are turned off.
Activate both and reload to view the mindmap
<%
import java.io.StringReader
import java.util.HashMap
import com.xpn.xwiki.doc.XWikiAttachment
import groovy.xml.MarkupBuilder
if (xwiki.hasAdminRights())
{
println "
Update the Group Map?"
if (request.get("updategm") != null)
{
print "Start mindmap generation… "
def sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='XWiki.XWikiGroups'"
def writer = new StringWriter()
def xmlBuilder = new MarkupBuilder(writer)
def nodes =
]
xmlBuilder.graph (title: "User Map", bgcolor:"ffffff", linecolor:"cccccc", viewmode:"explore", width:"725", height:"725") {
xmlBuilder.node (id: "root", text:"Groups", color:"ffffff")
for (item in xwiki.searchDocuments(sql)) {
def groupdoc = xwiki.getDocument(item)
xmlBuilder.node(id: groupdoc.getName(), text:groupdoc.getName(), color:"cccccc")
xmlBuilder.edge(sourceNode: "root", targetNode: groupdoc.getName(), label:"")
def users = groupdoc.getObjects("XWiki.XWikiGroups")
for (user in users) {
def hgapcount = 0
def totalCount = users.size()
def userName = xwiki.getUserName(user.getProperty("member").value)
userName = user.getProperty("member").value
def userdoc = xwiki.getDocument(userName)
if (userdoc != null) {
def attachCount = userdoc.attachmentList.size()
def attachIndex = attachCount - 1
def nodeURL = userdoc.getURL()
def nodeHtml = xwiki.getUserName(userName, false)
def userN = nodeHtml
def obj = userdoc.getObject("XWiki.XWikiUsers")
def attachURL = ""
if (obj != null) {
def lastname = obj.get("last_name")
def firstname = obj.get('first_name')
nodeHtml = firstname + ' ' + lastname
}
if (attachCount?
for (item in xwiki.searchDocuments(sql)) {
def username = xwiki.getUserName(item)
def user = xwiki.getUser(item)
//if (user.isUserInGroup("XWiki.DCNM2009")) {
usersArray.add(
criteria Service.revision Criteria Factory.create Revision Criteria(item), [?, 0])
//}
}
sql = ", BaseObject as obj"
def test = 0
for (item in xwiki.searchDocuments(sql)) {
def currDocument = xwiki.getDocument(item)
//checks if each user has editing this doc
for(currUser in usersArray) {
def revisions = currDocument.getRevisions(currUser
1?)
if(revisions.size() > 0) {
currUser
2?.add(revisions.size())
currUser
3? = currUser
3? + 1
}
else {
currUser
2?.add(0)
}
}
}
def distanceArray =
size()
for(i in 0..(dimension - 1)) {
def row = new double[dimension?
distanceArray.add(row)
//fill in previously calculated distances (symmetric matrix)
for(prev in 0..(i-1)) {
distanceArray
i?prev? = distanceArray
prev?i?
}
//calculate distances
if(i < (dimension - 1)) {
for(next in (i+1)..(dimension - 1)) {
//tanimoto distance
//calculate cross product of usersArray
i?2? and usersArray
next?2?
def totalShared = 0
for(k in 0..(usersArray
i?2?.size() - 1)) {
if(usersArray
i?2?k? != null && usersArray
next?2?k? != null) {
if(usersArray
i?2?k? * usersArray
next?2?k? > 0) {
totalShared += 1
}
}
}
def denom = (double)(usersArray
next?3?+ usersArray
i?3? - totalShared)
if(denom != 0) {
distanceArray
i?next? = totalShared / denom
} else {
distanceArray
i?next? = 0
}
}
}
}
//write out connection matrix to an attachment
def writer = new StringWriter()
def xmlBuilder = new MarkupBuilder(writer)
xmlBuilder.graph (title: "User Map", bgcolor:"ffffff", linecolor:"cccccc", viewmode:"explore", width:"725", height:"725"){
for(i in 0..(usersArray.size()-1)) {
if (distanceArray
i? != null> 0) {
def nonzero = distanceArray
i?.inject(0.0) { running, item -> running + item }
if (nonzero > 0.0) {
def userN = xwiki.getUserName( usersArray
i?0?, false)
xmlBuilder.node(id: userN, text: userN, color:"aaaaaa", nonzero:nonzero)
}
}
}
for(i in 0..(distanceArray.size()-2)) {
for(j in (i+1)..(distanceArray.size()-1)) {
if (distanceArray
i?j? > 0) {
def fromUser = xwiki.getUserName(usersArray
i?0?, false);
def toUser = xwiki.getUserName(usersArray
j?0?, false);
xmlBuilder.edge(sourceNode: fromUser, targetNode: toUser, distFactor:distanceArray
i?j?, label:"")
}
}
}
}
def attachmentName = "userdistances.xml"
def attachment = doc.getDocument().getAttachment(attachmentName)
if (!attachment){
attachment = new XWikiAttachment(doc.getDocument(), attachmentName)
doc.getDocument().getAttachmentList().add(attachment)
}
attachment.setContent(writer.toString().getBytes())
doc.getDocument().saveAttachmentContent(attachment, context.getContext())
doc.save()
println "Finished updating user relations."
} else {
println "
Update the User Relations?"
}
}
if(request.get("viewtoplsa") != null){
def users =
]
def distance Array = [?
def attachmentName = "lsa-creativeit2.csv"
def attachment = doc.getAttachment(attachmentName)
if (!attachment){
println "No lsa file found."
} else {
def content = attachment.getContentAsString()
def reader = new BufferedReader(new StringReader(content))
def userListStr = new StringTokenizer(reader.readLine(), ",")
// for(i in 1..size) {
while (userListStr.hasMoreTokens()) {
users.add(userListStr.nextToken())
}
def sortedDistanceMatrix =
.size) {
i = 0
while ((this Line = reader.read Line()) != null) {
i++
def distance Str = new String Tokenizer(this Line, ",")
def row = [?
j = 0
//for(j in 1..size) {
while (distanceStr.hasMoreTokens()) {
j++
row.add(
users[j-1?,Double.parseDouble(distanceStr.nextToken())])
}
//sort the row
for(j in 1..(row.size()-1)) {
def valueC = row
j?1?
def valueN = row
j?0?
def k = j-1
while(k >= 0 && row
k?1? < valueC) {
row
k + 1?0? = row
k?0?
row
k + 1?1? = row
k?1?
k = k-1
}
row
k+1?0? = valueN
row
k+1?1? = valueC
}
//prints users' top five connected people if they exist
print users
i-1? + ": "
for(j in 0..4) {
if(row
j?1? > 0) {
if(j > 0) {
print ", "
}
print xwiki.getUserName(row
j?0?)
}
}
println "n"
sortedDistanceMatrix.add(row)
}
}
} else {
println "
Show top lsa Relations?"
}
if(request.get("genlsa") != null){
def usersArray =
]
def distance Array = [?
def attachmentName = "lsa-creativeit2.csv"
def attachment = doc.getAttachment(attachmentName)
if (!attachment){
println "No lsa file found."
} else {
def content = attachment.getContentAsString()
def reader = new BufferedReader(new StringReader(content))
def userListStr = new StringTokenizer(reader.readLine(), ",")
// for(i in 1..size) {
while (userListStr.hasMoreTokens()) {
usersArray.add(userListStr.nextToken())
}
def sortedDistanceMatrix =
.size) {
i = 0
while ((this Line = reader.read Line()) != null) {
i++
def distance Str = new String Tokenizer(this Line, ",")
def row = [?
j = 0
//for(j in 1..size) {
while (distanceStr.hasMoreTokens()) {
j++
row.add(
users Array[j-1?,Double.parseDouble(distanceStr.nextToken())])
}
//sort the row
for(j in 1..(row.size()-1)) {
def valueC = row
j?1?
def valueN = row
j?0?
def k = j-1
while(k >= 0 && row
k?1? < valueC) {
row
k + 1?0? = row
k?0?
row
k + 1?1? = row
k?1?
k = k-1
}
row
k+1?0? = valueN
row
k+1?1? = valueC
}
sortedDistanceMatrix.add(row)
}
//write out connection matrix to an attachment
def writer = new StringWriter()
def xmlBuilder = new MarkupBuilder(writer)
xmlBuilder.graph (title: "Profile Closeness", bgcolor:"ffffff", linecolor:"cccccc", viewmode:"explore", width:"725", height:"725"){
for(i in 0..(usersArray.size()-1)) {
if (sortedDistanceMatrix
i? != null) {
def nonzero = sortedDistanceMatrix
i?.inject(0.0) { running, item -> running + item
1? }
if (nonzero > 0.0) {
def userN = xwiki.getUserName( usersArray
i?, false)
//userN = user.getProperty("member").value
def userdoc = xwiki.getDocument(usersArray
i?)
if (userdoc != null) {
def attachCount = userdoc.attachmentList.size()
def attachIndex = attachCount - 1
def nodeURL = userdoc.getURL()
def nodeHtml = xwiki.getUserName(userN, false)
userN = nodeHtml
def obj = userdoc.getObject("XWiki.XWikiUsers")
def attachURL = ""
if (obj != null) {
def lastname = obj.get("last_name")
def firstname = obj.get('first_name')
nodeHtml = firstname + ' ' + lastname
}
if (attachCount >0){
def attach = userdoc.attachmentList.get(0)
attachURL = userdoc.getAttachmentURL(attach.filename,"download") + "?width=90"
}
xmlBuilder.node(id: userN, text: nodeHtml, color:"aaaaaa", image: attachURL, link: nodeURL, nonzero: nonzero)
}
//xmlBuilder.node(id: userN, text: userN, color:"aaaaaa", nonzero:nonzero)
}
}
}
for(i in 0..(sortedDistanceMatrix.size()-1)) {
for(j in 1..5) {
if (sortedDistanceMatrix
i?j? != null) {
if (sortedDistanceMatrix
i?j?1? > 0) {
def fromUser = xwiki.getUserName(usersArray
i?, false);
def toUser = xwiki.getUserName(sortedDistanceMatrix
i?j?0?, false);
xmlBuilder.edge(sourceNode: fromUser, targetNode: toUser, distFactor: sortedDistanceMatrix
i?j?1?, label:"")
}
}
}
}
}
def outAttachmentName = "lsadistances.xml"
def outAttachment = doc.getDocument().getAttachment(outAttachmentName)
if (!outAttachment){
outAttachment = new XWikiAttachment(doc.getDocument(), outAttachmentName)
doc.getDocument().getAttachmentList().add(outAttachment)
}
outAttachment.setContent(writer.toString().getBytes())
doc.getDocument().saveAttachmentContent(outAttachment, context.getContext())
doc.save()
println "Finished updating lsa relations."
}
} else {
println "
generate graph for lsa Relations?"
}
if(request.get("genlsaxxx") != null){
def usersArray =
]
def distance Array = [?
def attachmentName = "lsa-creativeit2.csv"
def attachment = doc.getAttachment(attachmentName)
if (!attachment){
println "No lsa file found."
} else {
def content = attachment.getContentAsString()
def reader = new BufferedReader(new StringReader(content))
def userListStr = new StringTokenizer(reader.readLine(), ",")
// for(i in 1..size) {
while (userListStr.hasMoreTokens()) {
usersArray.add(userListStr.nextToken())
}
def sortedDistanceMatrix =
.size) {
i = 0
while ((this Line = reader.read Line()) != null) {
i++
def distance Str = new String Tokenizer(this Line, ",")
def row = [?
j = 0
//for(j in 1..size) {
while (distanceStr.hasMoreTokens()) {
j++
row.add(Double.parseDouble(distanceStr.nextToken()))
}
distanceArray.add(row)
}
}
//write out connection matrix to an attachment
def writer = new StringWriter()
def xmlBuilder = new MarkupBuilder(writer)
xmlBuilder.graph (title: "User Map", bgcolor:"ffffff", linecolor:"cccccc", viewmode:"explore", width:"725", height:"725"){
for(i in 0..(usersArray.size()-1)) {
if (distanceArray
i? != null> 0) {
def nonzero = distanceArray
i?.inject(0.0) { running, item -> running + item }
if (nonzero > 0.0) {
def userN = xwiki.getUserName( usersArray
i?, false)
xmlBuilder.node(id: userN, text: userN, color:"aaaaaa", nonzero:nonzero)
}
}
}
for(i in 0..(distanceArray.size()-2)) {
for(j in (i+1)..(distanceArray.size()-1)) {
if (distanceArray
i?j? > 0) {
def fromUser = xwiki.getUserName(usersArray
i?, false);
def toUser = xwiki.getUserName(usersArray
j?, false);
xmlBuilder.edge(sourceNode: fromUser, targetNode: toUser, distFactor:distanceArray
i?j?, label:"")
}
}
}
}
def outAttachmentName = "lsadistances.xml"
def outAttachment = doc.getDocument().getAttachment(outAttachmentName)
if (!outAttachment){
outAttachment = new XWikiAttachment(doc.getDocument(), outAttachmentName)
doc.getDocument().getAttachmentList().add(outAttachment)
}
outAttachment.setContent(writer.toString().getBytes())
doc.getDocument().saveAttachmentContent(outAttachment, context.getContext())
doc.save()
println "Finished updating lsa relations."
}
%>
user relations
Flash plugin or Javascript are turned off.
Activate both and reload to view the mindmap