Skip to content
Permalink
Browse files

added namespace definitions and reworked Project class

  • Loading branch information...
nicholsn committed Mar 28, 2012
1 parent 0e6200b commit aacc17bc239733723562defc8aaf5d53e2c94906
Showing with 77 additions and 30 deletions.
  1. +36 −2 tools/pyxcede/examples.py
  2. +41 −28 tools/pyxcede/pyxcede.py
@@ -39,5 +39,39 @@
# now that we have built up to hierarchy for a single project let's add it to the root XCEDE object
xcede = pyxcede.XCEDE(project=[projectA,])

# we can print out the project object to the terminal as xml by running this
xcede.export(sys.stdout,0)
# we can print out the project object to the terminal after adding a few namespaces
namespace = 'xmlns:prov="http://openprovenance.org/prov-xml#" '
namespace += 'xmlns:cu="http://www.w3.org/1999/xhtml/datatypes/" '
namespace += 'xmlns="http://www.xcede.org/xcede-2" '
namespace += 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
namespace += 'xsi:schemaLocation="http://www.xcede.org/xcede-2 http://...xcede-2.1-core.xsd" '
namespace += 'xmlns:xcede2="http://www.xcede.org/xcede-2" xcede2:version="version1"'

# and print it out
xcede.export(sys.stdout,0, namespacedef_= namespace)

'''
<xcede2:XCEDE xmlns:prov="http://openprovenance.org/prov-xml#" xmlns:cu="http://www.w3.org/1999/xhtml/datatypes/" xmlns="http://www.xcede.org/xcede-2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.xcede.org/xcede-2 xcede-2.1.1-core.xsd" xmlns:xcede2="http://www.xcede.org/xcede-2" xcede2:version="version1">
<xcede2:project termPath="http://usefulinc.com/ns/doap#Project" nomenclature="DOAP" abbreviation="proj-a" termID="Project" ID="projectA">
<xcede2:projectInfo>
<xcede2:description>This is ProjectA</xcede2:description>
<xcede2:subjectGroupList>
<xcede2:subjectGroup ID="groupA">
<xcede2:subjectID>subject1</xcede2:subjectID>
<xcede2:subjectID>subject2</xcede2:subjectID>
<xcede2:subjectID>subject3</xcede2:subjectID>
<xcede2:subjectID>subject4</xcede2:subjectID>
<xcede2:subjectID>subject5</xcede2:subjectID>
</xcede2:subjectGroup>
<xcede2:subjectGroup ID="groupB">
<xcede2:subjectID>subject6</xcede2:subjectID>
<xcede2:subjectID>subject7</xcede2:subjectID>
<xcede2:subjectID>subject8</xcede2:subjectID>
<xcede2:subjectID>subject9</xcede2:subjectID>
<xcede2:subjectID>subject10</xcede2:subjectID>
</xcede2:subjectGroup>
</xcede2:subjectGroupList>
</xcede2:projectInfo>
</xcede2:project>
</xcede2:XCEDE>
'''
@@ -25,8 +25,7 @@

import xcede_bindings as supermod

class Project(object):
# This is a mess... need feedback. I should probably just subclass the project_t class rather than
class Project(supermod.XCEDE):
"""
Project entity and associated setter/getter methods
The project entity can represent one or more projects, where each project consists of a
@@ -40,42 +39,56 @@ class Project(object):
Each level of the project hierarchy also has a set of attributes specific to the level
"""
def __init__(self, ID=None, abbreviation=None, name=None, description=None, uri=None):
self.ID = ID
self.abbreviation = abbreviation
self.name = name
self.description = description
self.uri = uri
# create project level instances of the required datatypes
self._xcedeType = supermod.XCEDE()
def __init__(self, project=None):
super(Project, self).__init__(project)

# these are attributes from the INCF API for the Project entity
#self.ID = ID
#self.abbreviation = abbreviation
#self.name = name
#self.description = description
#self.uri = uri
def get_project(self):
return self.project

def add_project(self, value):
"""
value is a list of project_t instances
"""
self.project.append(value)

def insert_project(self, index, value):
"""
index is an existing position in the project hierarchy, value is a project_t instance
"""
self.project[index] = value

def delete_project(self, ID):
"""
ID is the text of the projectID field
"""
for i in range(len(self.project)):
if self.project[i].ID == ID:
del(self.project[i])

def create_projectType(self):
self._projectType = supermod.project_t()

def create_projectInfoType(self):
self._projectInfoType = supermod.projectInfo_t()

def create_projectGroupListType(self):
self._subjectGroupListType = supermod.subjectGroupListType()

def create_subjectGroupType(self):
self._subjectGroupType = supermod.subjectGroup_t()

def set_ID(self,ID):
self._projectType.set_ID(ID=ID)
self.ID = self._projectType.get_ID()
def get_ID(self): return self.ID

def set_abbreviation(self,abbreviation): self._projectType.set_abbreviation(abbreviation)

def get_abbreviation(self): return self.abbreviation

def set_name(self):
pass
def get_name(self):
pass
def set_description(self):
pass
def get_description(self):
pass
def set_uri(self):
pass
def get_uri(self):
pass
self._resourceList = supermod.resourceListType()
self._resource = supermod.resource_t()
supermod.XCEDE.subclass = Project

etree_ = None
Verbose_import_ = False

0 comments on commit aacc17b

Please sign in to comment.
You can’t perform that action at this time.