Exemplo n.º 1
0
def storeObject(objectDict, practice):

    objects = ArrayList(1)
    objects.add(_getGenericRegistryObjectFromDict(objectDict))

    manager = GenericRegistryObjectManager(practice)
    manager.store(objects)
Exemplo n.º 2
0
def queryObjects(parameters, practice):

    # Iterate through the parameters, converting each into a Java object.
    queryParameters = ArrayList(len(parameters))
    for parameter in parameters:

        # Get the key and value, and the operand if the tuple is large
        # enough.
        key = parameter[0]
        if key is None:
            raise ValueError("query parameter key cannot be None")
        operand = (None if len(parameter) is 2 else parameter[1])
        value = (parameter[1] if len(parameter) is 2 else parameter[2])
        if value is None:
            raise ValueError("query parameter value cannot be None")
        multipleValues = isinstance(value, (list, set, tuple))
        if multipleValues:
            if len(value) == 0:
                raise ValueError(
                    "query parameter value cannot be empty collection")
            for valueElement in value:
                if valueElement is None:
                    raise ValueError(
                        "query parameter value collection cannot hold any elements with value of None"
                    )
        value = JUtil.pyValToJavaObj(value)
        if multipleValues:
            value = value.toArray()

        # Add the appropriately constructed Java object to the parameters
        # list.
        if operand is None:
            queryParameters.add(HazardQueryParameter(key, value))
        else:
            queryParameters.add(HazardQueryParameter(key, operand, value))

    # Create the query and submit it, and return the results.
    manager = GenericRegistryObjectManager(practice)
    map = manager.query(
        GenericRegistryObjectQueryRequest(practice, queryParameters))
    return _getDictsFromGenericRegistryObjects(map.values())
Exemplo n.º 3
0
def storeObjects(objectDicts, practice):

    objects = _getGenericRegistryObjectsFromDicts(objectDicts)

    manager = GenericRegistryObjectManager(practice)
    manager.store(objects)
Exemplo n.º 4
0
def removeAllObjects(practice):
    manager = GenericRegistryObjectManager(practice)
    manager.removeAll()