Ejemplo n.º 1
0
def getPlaylistResourceAnnotations(userId):
    """
	returns the ids of annotations by user that annotate resources found on playlists
	"""
    resourceIds = getPlaylistResources(userId)
    resourceResults = ResourceSearcher(resourceIds)
    #print "%d resources found" % len (resourceResults)
    ## print resourceResults[0]
    anno_ids = []
    add = anno_ids.append
    for result in resourceResults:
        result.xpath_delimiter = '/'
        #print result.recId
        relations = result.selectNodes(result.dom,
                                       'record/relations/relation/record')
        #print ' %d relations found' % len(relations)

        # now find the relation that is a annotationRecord and is contributed by our user
        for rel in relations:
            idPath = "metadata/annotationRecord/moreInfo/userSelection/user/userId"
            if XmlUtils.getTextAtPath(rel, idPath) == userId:
                anno_id = XmlUtils.getTextAtPath(rel, 'head/id')
                if not anno_id in anno_ids:
                    add(anno_id)
    return anno_ids
Ejemplo n.º 2
0
 def __init__(self, did_element):
     if not did_element:
         raise Exception, "did_element is NONE"
     self.element = did_element
     self.unittitle = XmlUtils.getTextAtPath(did_element, "unittitle/title")
     self.unitid = XmlUtils.getTextAtPath(did_element, "unitid")
     self.containerElements = XmlUtils.selectNodes(self.element,
                                                   "container")
     self.physdescElements = XmlUtils.selectNodes(self.element, "physdesc")
Ejemplo n.º 3
0
    def getConnections(self):

        # print 'getConnections'
        if self.connections is None:
            conns = UserDict()
            pinX = float(self.get('PinX'))
            pinY = float(self.get('PinY'))
            # print ' - pinY: %f, pinX: %f' % (pinX, pinY)
            for node in self.selectNodes(self.dom, 'Shape/Connection'):
                id = XmlUtils.getTextAtPath(node, '@ID')
                name = XmlUtils.getTextAtPath(node, '@Name')
                x = float(XmlUtils.getTextAtPath(node, 'X'))
                y = float(XmlUtils.getTextAtPath(node, 'Y'))
                conns[name] = (x + pinX, y + pinY)
                # conns[id] = (x+pinX, y+pinY)
            self.connections = conns
        return self.connections
Ejemplo n.º 4
0
    def __init__(self, element):
        """
		"""
        self.key = XmlUtils.getTextAtPath(element, 'searchKey')
        self.recordId = XmlUtils.getTextAtPath(element, 'recordId')

        self.xmlFormat = XmlUtils.getTextAtPath(
            element, 'additionalMetadata/dlese_collect/formatOfRecords')
        self.numRecords = XmlUtils.getTextAtPath(
            element, 'additionalMetadata/dlese_collect/numRecords')
        if self.numRecords:
            try:
                self.numRecords = int(self.numRecords)
            except:
                print "could not convert numRecords (%s) to integer: %s" % (
                    self.numRecords, sys.exc_info()[1])
        if not self.numRecords:
            self.numRecords = 0
Ejemplo n.º 5
0
	def getUsernameWorks(self):
		nodes = self.payload.selectNodes(self.payload.dom, 'java:object:void')
		for node in nodes:
			print 'property: ', node.getAttribute('property')
			if node.getAttribute('property') == 'username':
				print node.toxml()
				username = XmlUtils.getTextAtPath(node, 'string')
				return username
		return 'unknown'
Ejemplo n.º 6
0
def getUserSelectionAnno(userId, recordId):
    result = getUserResource(userId, recordId)
    if result is None:
        raise Exception, "record not found for '%s'" % recordId

    # find the anno for this user
    selectPath = 'record:relations:relation:record:metadata:annotationRecord:moreInfo:userSelection:@selectedByUserId'
    relationAnnos = result.selectNodes(result.dom, 'record:relations:relation')
    print '%d relationAnnos' % len(relationAnnos)
    for anno in result.selectNodes(
            result.dom,
            'record:relations:relation:record:metadata:annotationRecord'):
        itemID = XmlUtils.getTextAtPath(anno, 'itemID')
        print 'itemID', itemID
        print result.xpath_delimiter
        if userId == XmlUtils.getTextAtPath(
                anno, 'moreInfo:userSelection:@selectedByUserId', ':'):
            return DleseAnnoRecord(xml=anno.toxml())
Ejemplo n.º 7
0
    def __init__(self, element=None, data=None):

        self.description_path = qp("annotation/documentation")

        if element is not None:
            # print "AnnotatedVocabTerm with element of type %s" % type(element)
            self.value = element.getAttribute("value")
            self.description = XmlUtils.getTextAtPath(element,
                                                      self.description_path)
        if data is not None:
            self.value = data[0]
            self.description = data[1]
Ejemplo n.º 8
0
 def __init__(self, result):
     collectionRecord = result.payload
     self.title = XmlUtils.getTextAtPath(collectionRecord.dom,
                                         self.title_path)
     self.key = XmlUtils.getTextAtPath(collectionRecord.dom, self.key_path)
Ejemplo n.º 9
0
		def format_name (node):
			print 'format_name'
			first = XmlUtils.getTextAtPath(node, "namePart[@type='given']")
			last = XmlUtils.getTextAtPath(node, "namePart[@type='family']")

			return '%s, %s.' % (last, first[0])