Skip to content

Commit

Permalink
2.4 (#117)
Browse files Browse the repository at this point in the history
* Initial version of 2.4
  • Loading branch information
andamian authored Nov 12, 2019
1 parent 3ddef4b commit 21bddd1
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 64 deletions.
4 changes: 2 additions & 2 deletions caom2/caom2/caom_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ def validate_path_component(caller, name, test):
is invalid
"""

if ' ' in test or '/' in test or '||' in test or '%' in test:
if ' ' in test or '||' in test or '%' in test:
raise \
ValueError(caller.__class__.__name__ + ": invalid " + name +
": may not contain space ( ), slash (/), escape (\\), "
": may not contain space ( ), escape (\\), "
"or percent (%)")


Expand Down
2 changes: 2 additions & 0 deletions caom2/caom2/checksum.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ def update_caom_checksum(checksum, entity, parent=None):
# get the id first
if isinstance(entity, AbstractCaomEntity):
update_checksum(checksum, entity._id)
if entity._meta_producer:
update_checksum(checksum, entity._meta_producer)

# determine the excluded fields if necessary
checksum_excluded_fields = []
Expand Down
20 changes: 5 additions & 15 deletions caom2/caom2/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,14 @@ def __repr__(self):
class AbstractCaomEntity(CaomObject):
"""Class that defines the persistence unique ID and last mod date """

def __init__(self, fulluuid=True):
def __init__(self, fulluuid=True, meta_producer=None):
super(CaomObject, self).__init__()
self._id = AbstractCaomEntity._gen_id(fulluuid)
self.last_modified = None
self.max_last_modified = None
self.meta_checksum = None
self.acc_meta_checksum = None
self.meta_producer = None
self._meta_producer = meta_producer

@classmethod
def _gen_id(cls, fulluuid=True):
Expand Down Expand Up @@ -273,24 +273,14 @@ def acc_meta_checksum(self, value):
False)
self._acc_meta_checksum = value

@property
def meta_producer(self):
"""TBD
def get_meta_producer(self):
"""
Returns meta producer
type: URI
"""
return self._meta_producer

@meta_producer.setter
def meta_producer(self, value):
if value is None:
self._meta_producer = None
else:
caom_util.type_check(value, ChecksumURI, "meta_producer",
False)
self._meta_producer = value


class VocabularyTerm(object):
""" VocabularyTerm """
Expand Down
7 changes: 7 additions & 0 deletions caom2/caom2/obs_reader_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ def _set_entity_attributes(self, element, ns, caom2_entity):
element_max_last_modified = element.get("{" + ns + "}maxLastModified")
element_meta_checksum = element.get("{" + ns + "}metaChecksum")
element_acc_meta_checksum = element.get("{" + ns + "}accMetaChecksum")
element_meta_producer = element.get("{" + ns + "}metaProducer")

caom2_entity._id = uuid.UUID(element_id)

Expand All @@ -181,6 +182,9 @@ def _set_entity_attributes(self, element, ns, caom2_entity):
if element_acc_meta_checksum:
caom2_entity._acc_meta_checksum = common.ChecksumURI(
element_acc_meta_checksum)
if element_meta_producer:
caom2_entity._meta_producer = common.ChecksumURI(
element_meta_producer)

def _get_child_element(self, element_tag, parent, ns, required):
for element in list(parent):
Expand Down Expand Up @@ -1913,6 +1917,9 @@ def _add_entity_attributes(self, entity, element):
if entity._acc_meta_checksum is not None:
self._add_attribute(
"accMetaChecksum", entity._acc_meta_checksum.uri, element)
if entity._meta_producer is not None:
self._add_attribute(
"metaProducer", entity.get_meta_producer().uri, element)

def _add_algorithm_element(self, algorithm, parent):
if algorithm is None:
Expand Down
Loading

0 comments on commit 21bddd1

Please sign in to comment.