text stringlengths 81 112k |
|---|
Update an entire network
def update_network(network,
update_nodes = True,
update_links = True,
update_groups = True,
update_scenarios = True,
**kwargs):
"""
Update an entire network
"""
log.info("Updating Network %s", network.name)
user_id = kwargs.get('user_id')
#check_... |
Activates a network by setting its status attribute to 'A'.
def set_network_status(network_id,status,**kwargs):
"""
Activates a network by setting its status attribute to 'A'.
"""
user_id = kwargs.get('user_id')
#check_perm(user_id, 'delete_network')
try:
net_i = db.DBSession.query(Netw... |
Given a network, return its maximum extents.
This would be the minimum x value of all nodes,
the minimum y value of all nodes,
the maximum x value of all nodes and
maximum y value of all nodes.
@returns NetworkExtents object
def get_network_extents(network_id,**kwargs):
"""
Given a network... |
Add nodes to network
def add_nodes(network_id, nodes,**kwargs):
"""
Add nodes to network
"""
start_time = datetime.datetime.now()
names=[] # used to check uniqueness of node name
for n_i in nodes:
if n_i.name in names:
raise HydraError("Duplicate Node Name: %s"%(... |
add links to network
def add_links(network_id, links,**kwargs):
'''
add links to network
'''
start_time = datetime.datetime.now()
user_id = kwargs.get('user_id')
names=[] # used to check uniqueness of link name before saving links to database
for l_i in links:
if l_i.name in ... |
Update a node.
If new attributes are present, they will be added to the node.
The non-presence of attributes does not remove them.
The flush argument indicates whether dbsession.flush should be called. THis
is set to False when update_node is called from another function which does
the flush.
def ... |
Update multiple nodes.
If new attributes are present, they will be added to the node.
The non-presence of attributes does not remove them.
%TODO:merge this with the 'update_nodes' functionality in the 'update_netework'
function, so we're not duplicating functionality. D.R.Y!
returns: a list of upd... |
Set the status of a node to 'X'
def set_node_status(node_id, status, **kwargs):
"""
Set the status of a node to 'X'
"""
user_id = kwargs.get('user_id')
try:
node_i = db.DBSession.query(Node).filter(Node.id == node_id).one()
except NoResultFound:
raise ResourceNotFoundError("... |
Remove a network from DB completely
Use purge_data to try to delete the data associated with only this network.
If no other resources link to this data, it will be deleted.
def purge_network(network_id, purge_data,**kwargs):
"""
Remove a network from DB completely
Use purge_data to ... |
Find the number of times a a resource and dataset combination
occurs. If this equals the number of times the dataset appears, then
we can say this dataset is unique to this resource, therefore it can be deleted
def _purge_datasets_unique_to_resource(ref_key, ref_id):
"""
Find the number of ... |
Remove node from DB completely
If there are attributes on the node, use purge_data to try to
delete the data. If no other resources link to this data, it
will be deleted.
def delete_node(node_id, purge_data,**kwargs):
"""
Remove node from DB completely
If there are attribute... |
Add a link to a network
def add_link(network_id, link,**kwargs):
"""
Add a link to a network
"""
user_id = kwargs.get('user_id')
#check_perm(user_id, 'edit_topology')
try:
net_i = db.DBSession.query(Network).filter(Network.id == network_id).one()
net_i.check_write_permissio... |
Update a link.
def update_link(link,**kwargs):
"""
Update a link.
"""
user_id = kwargs.get('user_id')
#check_perm(user_id, 'edit_topology')
try:
link_i = db.DBSession.query(Link).filter(Link.id == link.id).one()
link_i.network.check_write_permission(user_id)
except NoRes... |
Set the status of a link
def set_link_status(link_id, status, **kwargs):
"""
Set the status of a link
"""
user_id = kwargs.get('user_id')
#check_perm(user_id, 'edit_topology')
try:
link_i = db.DBSession.query(Link).filter(Link.id == link_id).one()
except NoResultFound:
r... |
Remove link from DB completely
If there are attributes on the link, use purge_data to try to
delete the data. If no other resources link to this data, it
will be deleted.
def delete_link(link_id, purge_data,**kwargs):
"""
Remove link from DB completely
If there are attribute... |
Add a resourcegroup to a network
def add_group(network_id, group,**kwargs):
"""
Add a resourcegroup to a network
"""
user_id = kwargs.get('user_id')
try:
net_i = db.DBSession.query(Network).filter(Network.id == network_id).one()
net_i.check_write_permission(user_id=user_id)
... |
Update a group.
If new attributes are present, they will be added to the group.
The non-presence of attributes does not remove them.
def update_group(group,**kwargs):
"""
Update a group.
If new attributes are present, they will be added to the group.
The non-presence of attr... |
Set the status of a group to 'X'
def set_group_status(group_id, status, **kwargs):
"""
Set the status of a group to 'X'
"""
user_id = kwargs.get('user_id')
try:
group_i = db.DBSession.query(ResourceGroup).filter(ResourceGroup.id == group_id).one()
except NoResultFound:
raise... |
Remove group from DB completely
If there are attributes on the group, use purge_data to try to
delete the data. If no other resources group to this data, it
will be deleted.
def delete_group(group_id, purge_data,**kwargs):
"""
Remove group from DB completely
If there are att... |
Get all the scenarios in a given network.
def get_scenarios(network_id,**kwargs):
"""
Get all the scenarios in a given network.
"""
user_id = kwargs.get('user_id')
try:
net_i = db.DBSession.query(Network).filter(Network.id == network_id).one()
net_i.check_read_permission(user_i... |
Check for the presence of orphan nodes in a network.
def validate_network_topology(network_id,**kwargs):
"""
Check for the presence of orphan nodes in a network.
"""
user_id = kwargs.get('user_id')
try:
net_i = db.DBSession.query(Network).filter(Network.id == network_id).one()
... |
Return the Nodes, Links and ResourceGroups which
have the type specified.
def get_resources_of_type(network_id, type_id, **kwargs):
"""
Return the Nodes, Links and ResourceGroups which
have the type specified.
"""
nodes_with_type = db.DBSession.query(Node).join(ResourceType).filter... |
Purge any deleted nodes, links, resourcegroups and scenarios in a given network
def clean_up_network(network_id, **kwargs):
"""
Purge any deleted nodes, links, resourcegroups and scenarios in a given network
"""
user_id = kwargs.get('user_id')
#check_perm(user_id, 'delete_network')
try:
... |
Find every resource attribute in the network matching the supplied attr_id
def get_all_resource_attributes_in_network(attr_id, network_id, **kwargs):
"""
Find every resource attribute in the network matching the supplied attr_id
"""
user_id = kwargs.get('user_id')
try:
a = db.DBSessio... |
A function which returns the data for all resources in a network.
-
def get_all_resource_data(scenario_id, include_metadata='N', page_start=None, page_end=None, **kwargs):
"""
A function which returns the data for all resources in a network.
-
"""
rs_qry = db.DBSession.query(
... |
Create an exact clone of the specified network for the specified user.
If project_id is specified, put the new network in there.
Otherwise create a new project with the specified name and put it in there.
def clone_network(network_id, recipient_user_id=None, new_network_name=None, project_id=None, project_... |
For a given list of resource attribute IDS copy the dataset_ids from
the resource scenarios in the source scenario to those in the 'target' scenario.
def copy_data_from_scenario(resource_attrs, source_scenario_id, target_scenario_id, **kwargs):
"""
For a given list of resource attribute IDS copy th... |
Get the specified scenario
def get_scenario(scenario_id,**kwargs):
"""
Get the specified scenario
"""
user_id = kwargs.get('user_id')
scen_i = _get_scenario(scenario_id, user_id)
scen_j = JSONObject(scen_i)
rscen_rs = db.DBSession.query(ResourceScenario).filter(ResourceScenario.scena... |
Add a scenario to a specified network.
def add_scenario(network_id, scenario,**kwargs):
"""
Add a scenario to a specified network.
"""
user_id = int(kwargs.get('user_id'))
log.info("Adding scenarios to network")
_check_network_ownership(network_id, user_id)
existing_scen = db.DBSessio... |
Update a single scenario
as all resources already exist, there is no need to worry
about negative IDS
flush = True flushes to the DB at the end of the function.
flush = False does not flush, assuming that it will happen as part
of another process, like update_network.
d... |
Set the status of a scenario.
def set_scenario_status(scenario_id, status, **kwargs):
"""
Set the status of a scenario.
"""
user_id = kwargs.get('user_id')
_check_can_edit_scenario(scenario_id, kwargs['user_id'])
scenario_i = _get_scenario(scenario_id, user_id)
scenario_i.status = s... |
Set the status of a scenario.
def purge_scenario(scenario_id, **kwargs):
"""
Set the status of a scenario.
"""
_check_can_edit_scenario(scenario_id, kwargs['user_id'])
user_id = kwargs.get('user_id')
scenario_i = _get_scenario(scenario_id, user_id)
db.DBSession.delete(scenario_i)
... |
Turn a dictionary into a named tuple so it can be
passed into the constructor of a complex model generator.
def _get_as_obj(obj_dict, name):
"""
Turn a dictionary into a named tuple so it can be
passed into the constructor of a complex model generator.
"""
if obj_dict.get('_sa_insta... |
Get the resource scenario object for a given resource atttribute and scenario.
This is done when you know the attribute, resource and scenario and want to get the
value associated with it.
def get_resource_scenario(resource_attr_id, scenario_id, **kwargs):
"""
Get the resource scenario obje... |
Update the data associated with a list of scenarios.
def bulk_update_resourcedata(scenario_ids, resource_scenarios,**kwargs):
"""
Update the data associated with a list of scenarios.
"""
user_id = kwargs.get('user_id')
res = None
res = {}
net_ids = db.DBSession.query(Scenario.network_... |
Update the data associated with a scenario.
Data missing from the resource scenario will not be removed
from the scenario. Use the remove_resourcedata for this task.
If the resource scenario does not exist, it will be created.
If the value of the resource scenario is specified as being ... |
Remove the data associated with a resource in a scenario.
def delete_resource_scenario(scenario_id, resource_attr_id, quiet=False, **kwargs):
"""
Remove the data associated with a resource in a scenario.
"""
_check_can_edit_scenario(scenario_id, kwargs['user_id'])
_delete_resourcescenario(scen... |
Remove the data associated with a resource in a scenario.
The 'quiet' parameter indicates whether an non-existent RS should throw
an error.
def delete_resourcedata(scenario_id, resource_scenario, quiet = False, **kwargs):
"""
Remove the data associated with a resource in a scenario.
... |
Insert or Update the value of a resource's attribute by first getting the
resource, then parsing the input data, then assigning the value.
returns a ResourceScenario object.
def _update_resourcescenario(scenario, resource_scenario, dataset=None, new=False, user_id=None, source=None):
"""
I... |
Insert or update a piece of data in a scenario.
If the dataset is being shared by other resource scenarios, a new dataset is inserted.
If the dataset is ONLY being used by the resource scenario in question, the dataset
is updated to avoid unnecessary duplication.
def assign_value(rs, data_type,... |
Add data to a resource scenario outside of a network update
def add_data_to_attribute(scenario_id, resource_attr_id, dataset,**kwargs):
"""
Add data to a resource scenario outside of a network update
"""
user_id = kwargs.get('user_id')
_check_can_edit_scenario(scenario_id, user_id)
scenar... |
Get all the datasets from the group with the specified name
@returns a list of dictionaries
def get_scenario_data(scenario_id,**kwargs):
"""
Get all the datasets from the group with the specified name
@returns a list of dictionaries
"""
user_id = kwargs.get('user_id')
scenario_... |
For a given attribute or set of attributes, return all the resources and
resource scenarios in the network
def get_attribute_data(attr_ids, node_ids, **kwargs):
"""
For a given attribute or set of attributes, return all the resources and
resource scenarios in the network
"""
node_... |
Get all the resource scenarios for a given resource
in a given scenario. If type_id is specified, only
return the resource scenarios for the attributes
within the type.
def get_resource_data(ref_key, ref_id, scenario_id, type_id=None, expunge_session=True, **kwargs):
"""
Get all the... |
Retrieve all the datasets in a scenario for a given attribute.
Also return the resource attributes so there is a reference to the node/link
def get_attribute_datasets(attr_id, scenario_id, **kwargs):
"""
Retrieve all the datasets in a scenario for a given attribute.
Also return the resource... |
Get all the items in a group, in a scenario. If group_id is None, return
all items across all groups in the scenario.
def get_resourcegroupitems(group_id, scenario_id, **kwargs):
"""
Get all the items in a group, in a scenario. If group_id is None, return
all items across all groups in the... |
Delete specified items in a group, in a scenario.
def delete_resourcegroupitems(scenario_id, item_ids, **kwargs):
"""
Delete specified items in a group, in a scenario.
"""
user_id = int(kwargs.get('user_id'))
#check the scenario exists
_get_scenario(scenario_id, user_id)
for item_id in ... |
Delete all itemas in a group, in a scenario.
def empty_group(group_id, scenario_id, **kwargs):
"""
Delete all itemas in a group, in a scenario.
"""
user_id = int(kwargs.get('user_id'))
#check the scenario exists
_get_scenario(scenario_id, user_id)
rgi = db.DBSession.query(ResourceGroup... |
Get all the items in a group, in a scenario.
def add_resourcegroupitems(scenario_id, items, scenario=None, **kwargs):
"""
Get all the items in a group, in a scenario.
"""
user_id = int(kwargs.get('user_id'))
if scenario is None:
scenario = _get_scenario(scenario_id, user_id)
_che... |
Add a single resource group item (no DB flush, as it's an internal function)
def _add_resourcegroupitem(group_item, scenario_id):
"""
Add a single resource group item (no DB flush, as it's an internal function)
"""
if group_item.id and group_item.id > 0:
try:
group_item_i = db.D... |
Using a resource attribute mapping, take the value from the source and apply
it to the target. Both source and target scenarios must be specified (and therefor
must exist).
def update_value_from_mapping(source_resource_attr_id, target_resource_attr_id, source_scenario_id, target_scenario_id, **kwargs):... |
Get all available plugins
def get_plugins(**kwargs):
"""
Get all available plugins
"""
plugins = []
plugin_paths = []
#Look in directory or set of directories for
#plugins
base_plugin_dir = config.get('plugin', 'default_directory')
plugin_xsd_path = config.get('pl... |
Run a plugin
def run_plugin(plugin,**kwargs):
"""
Run a plugin
"""
args = [sys.executable]
#Get plugin executable
home = os.path.expanduser('~')
path_to_plugin = os.path.join(home, 'svn/HYDRA/HydraPlugins', plugin.location)
args.append(path_to_plugin)
#Parse plugin arg... |
Load a config file. This function looks for a config (*.ini) file in the
following order::
(1) ./*.ini
(2) ~/.config/hydra/
(3) /etc/hydra
(4) /path/to/hydra_base/*.ini
(1) will override (2) will override (3) will override (4). Parameters not
defined in (1) will be taken fr... |
To simplify deployment, create the mysql DB if it's not there.
Accepts a URL with or without a DB name stated, and returns a db url
containing the db name for use in the main sqlalchemy engine.
THe formats can take the following form:
mysql+driver://username:password@hostname
m... |
Add a new project
returns a project complexmodel
def add_project(project,**kwargs):
"""
Add a new project
returns a project complexmodel
"""
user_id = kwargs.get('user_id')
existing_proj = get_project_by_name(project.name,user_id=user_id)
if len(existing_proj) > 0:
... |
Update a project
returns a project complexmodel
def update_project(project,**kwargs):
"""
Update a project
returns a project complexmodel
"""
user_id = kwargs.get('user_id')
#check_perm(user_id, 'update_project')
proj_i = _get_project(project.id)
proj_i.check_write_per... |
get a project complexmodel
def get_project(project_id, include_deleted_networks=False, **kwargs):
"""
get a project complexmodel
"""
user_id = kwargs.get('user_id')
proj_i = _get_project(project_id)
#lazy load owners
proj_i.owners
proj_i.check_read_permission(user_id)
proj_j ... |
get a project complexmodel by a network_id
def get_project_by_network_id(network_id,**kwargs):
"""
get a project complexmodel by a network_id
"""
user_id = kwargs.get('user_id')
projects_i = db.DBSession.query(Project).join(ProjectOwner).join(Network, Project.id==Network.project_id).filter(
... |
get a project complexmodel
def get_project_by_name(project_name,**kwargs):
"""
get a project complexmodel
"""
user_id = kwargs.get('user_id')
projects_i = db.DBSession.query(Project).join(ProjectOwner).filter(
Project.name==project_name,
... |
Altered from an example found on stackoverflow
http://stackoverflow.com/questions/23554119/convert-sqlalchemy-orm-result-to-dict
def to_named_tuple(obj, visited_children=None, back_relationships=None, levels=None, ignore=[], extras={}):
"""
Altered from an example found on stackoverflow
htt... |
Get all the projects owned by the specified user.
These include projects created by the user, but also ones shared with the user.
For shared projects, only include networks in those projects which are accessible to the user.
the include_shared_projects flag indicates whether to include projects... |
Set the status of a project to 'X'
def set_project_status(project_id, status, **kwargs):
"""
Set the status of a project to 'X'
"""
user_id = kwargs.get('user_id')
#check_perm(user_id, 'delete_project')
project = _get_project(project_id)
project.check_write_permission(user_id)
proje... |
Set the status of a project to 'X'
def delete_project(project_id,**kwargs):
"""
Set the status of a project to 'X'
"""
user_id = kwargs.get('user_id')
#check_perm(user_id, 'delete_project')
project = _get_project(project_id)
project.check_write_permission(user_id)
db.DBSession.delet... |
Get all networks in a project
Returns an array of network objects.
def get_networks(project_id, include_data='N', **kwargs):
"""
Get all networks in a project
Returns an array of network objects.
"""
log.info("Getting networks for project %s", project_id)
user_id = kwargs.get('u... |
get the project that a network is in
def get_network_project(network_id, **kwargs):
"""
get the project that a network is in
"""
net_proj = db.DBSession.query(Project).join(Network, and_(Project.id==Network.id, Network.id==network_id)).first()
if net_proj is None:
raise HydraError("Ne... |
Save a reference to the types used for this resource.
@returns a list of type_ids representing the type ids
on the resource.
def add_resource_types(resource_i, types):
"""
Save a reference to the types used for this resource.
@returns a list of type_ids representing the type ids
on the resour... |
Adds the roles and perm to the DB. It adds only roles, perms and links between them that are not inside the db
It is possible adding new role or perm and connecting them just modifiying the following lists
def create_default_users_and_perms():
"""
Adds the roles and perm to the DB. It adds only rol... |
Adds the units and the dimensions reading a json file. It adds only dimensions and units that are not inside the db
It is possible adding new dimensions and units to the DB just modifiyin the json file
def create_default_units_and_dimensions():
"""
Adds the units and the dimensions reading a json f... |
Gets a dimension from the DB table.
def get_dimension_from_db_by_name(dimension_name):
"""
Gets a dimension from the DB table.
"""
try:
dimension = db.DBSession.query(Dimension).filter(Dimension.name==dimension_name).one()
return JSONObject(dimension)
except NoResultFound:
... |
Get all the rules for a given scenario.
def get_rules(scenario_id, **kwargs):
"""
Get all the rules for a given scenario.
"""
rules = db.DBSession.query(Rule).filter(Rule.scenario_id==scenario_id, Rule.status=='A').all()
return rules |
Get a specific attribute by its ID.
def get_attribute_by_id(attr_id, **kwargs):
"""
Get a specific attribute by its ID.
"""
try:
attr_i = db.DBSession.query(Attr).filter(Attr.id==attr_id).one()
return attr_i
except NoResultFound:
return None |
Get a specific attribute by its ID.
def get_template_attributes(template_id, **kwargs):
"""
Get a specific attribute by its ID.
"""
try:
attrs_i = db.DBSession.query(Attr).filter(TemplateType.template_id==template_id).filter(TypeAttr.type_id==TemplateType.id).filter(Attr.id==TypeAttr.id).a... |
Get a specific attribute by its name.
dimension_id can be None, because in attribute the dimension_id is not anymore mandatory
def get_attribute_by_name_and_dimension(name, dimension_id=None,**kwargs):
"""
Get a specific attribute by its name.
dimension_id can be None, because in attribute ... |
Add a generic attribute, which can then be used in creating
a resource attribute, and put into a type.
.. code-block:: python
(Attr){
id = 1020
name = "Test Attr"
dimension_id = 123
}
def add_attribute(attr,**kwargs):
"""
Add a generic attribute, wh... |
Add a generic attribute, which can then be used in creating
a resource attribute, and put into a type.
.. code-block:: python
(Attr){
id = 1020
name = "Test Attr"
dimension_id = 123
}
def update_attribute(attr,**kwargs):
"""
Add a generic attribute,... |
Add a list of generic attributes, which can then be used in creating
a resource attribute, and put into a type.
.. code-block:: python
(Attr){
id = 1020
name = "Test Attr"
dimen = "very big"
}
def add_attributes(attrs,**kwargs):
"""
Add a list of ge... |
Get all attributes
def get_attributes(**kwargs):
"""
Get all attributes
"""
attrs = db.DBSession.query(Attr).order_by(Attr.name).all()
return attrs |
Deletes a resource attribute and all associated data.
def update_resource_attribute(resource_attr_id, is_var, **kwargs):
"""
Deletes a resource attribute and all associated data.
"""
user_id = kwargs.get('user_id')
try:
ra = db.DBSession.query(ResourceAttr).filter(ResourceAttr.id == res... |
Deletes a resource attribute and all associated data.
def delete_resource_attribute(resource_attr_id, **kwargs):
"""
Deletes a resource attribute and all associated data.
"""
user_id = kwargs.get('user_id')
try:
ra = db.DBSession.query(ResourceAttr).filter(ResourceAttr.id == resource_at... |
Add a resource attribute attribute to a resource.
attr_is_var indicates whether the attribute is a variable or not --
this is used in simulation to indicate that this value is expected
to be filled in by the simulator.
def add_resource_attribute(resource_type, resource_id, attr_id, is_var, err... |
adds all the attributes defined by a type to a node.
def add_resource_attrs_from_type(type_id, resource_type, resource_id,**kwargs):
"""
adds all the attributes defined by a type to a node.
"""
type_i = _get_templatetype(type_id)
resource_i = _get_resource(resource_type, resource_id)
reso... |
Get all the resource attributes for a given resource type in the network.
That includes all the resource attributes for a given type within the network.
For example, if the ref_key is 'NODE', then it will return all the attirbutes
of all nodes in the network. This function allows a front end to ... |
Get all the resource attributes for a given resource.
If type_id is specified, only
return the resource attributes within the type.
def get_resource_attributes(ref_key, ref_id, type_id=None, **kwargs):
"""
Get all the resource attributes for a given resource.
If type_id is specified... |
Check that the dimension of the resource attribute data is consistent
with the definition of the attribute.
If the attribute says 'volume', make sure every dataset connected
with this attribute via a resource attribute also has a dimension
of 'volume'.
def check_attr_dimension(attr_id, ... |
Get a specific resource attribte, by ID
If type_id is Gspecified, only
return the resource attributes within the type.
def get_resource_attribute(resource_attr_id, **kwargs):
"""
Get a specific resource attribte, by ID
If type_id is Gspecified, only
return the resource attri... |
Define one resource attribute from one network as being the same as
that from another network.
def set_attribute_mapping(resource_attr_a, resource_attr_b, **kwargs):
"""
Define one resource attribute from one network as being the same as
that from another network.
"""
user_id = kwar... |
Define one resource attribute from one network as being the same as
that from another network.
def delete_attribute_mapping(resource_attr_a, resource_attr_b, **kwargs):
"""
Define one resource attribute from one network as being the same as
that from another network.
"""
user_id = k... |
Delete all the resource attribute mappings in a network. If another network
is specified, only delete the mappings between the two networks.
def delete_mappings_in_network(network_id, network_2_id=None, **kwargs):
"""
Delete all the resource attribute mappings in a network. If another network
... |
Get all the resource attribute mappings in a network. If another network
is specified, only return the mappings between the two networks.
def get_mappings_in_network(network_id, network_2_id=None, **kwargs):
"""
Get all the resource attribute mappings in a network. If another network
is spe... |
Get all the resource attribute mappings in a network. If another network
is specified, only return the mappings between the two networks.
def get_node_mappings(node_id, node_2_id=None, **kwargs):
"""
Get all the resource attribute mappings in a network. If another network
is specified, only... |
Get all the resource attribute mappings in a network. If another network
is specified, only return the mappings between the two networks.
def get_link_mappings(link_id, link_2_id=None, **kwargs):
"""
Get all the resource attribute mappings in a network. If another network
is specified, only... |
Get all the mappings of network resource attributes, NOT ALL THE MAPPINGS
WITHIN A NETWORK. For that, ``use get_mappings_in_network``. If another network
is specified, only return the mappings between the two networks.
def get_network_mappings(network_id, network_2_id=None, **kwargs):
"""
G... |
Check whether an attribute mapping exists between a source and target resource attribute.
returns 'Y' if a mapping exists. Returns 'N' in all other cases.
def check_attribute_mapping_exists(resource_attr_id_source, resource_attr_id_target, **kwargs):
"""
Check whether an attribute mapping exists be... |
Get a specific attribute group
def get_attribute_group(group_id, **kwargs):
"""
Get a specific attribute group
"""
user_id=kwargs.get('user_id')
try:
group_i = db.DBSession.query(AttrGroup).filter(
AttrGroup.id==group_id).one()
group... |
Add a new attribute group.
An attribute group is a container for attributes which need to be grouped
in some logical way. For example, if the 'attr_is_var' flag isn't expressive
enough to delineate different groupings.
an attribute group looks like:
{
'proje... |
Add a new attribute group.
An attribute group is a container for attributes which need to be grouped
in some logical way. For example, if the 'attr_is_var' flag isn't expressive
enough to delineate different groupings.
an attribute group looks like:
{
'proje... |
Delete an attribute group.
def delete_attribute_group(group_id, **kwargs):
"""
Delete an attribute group.
"""
user_id = kwargs['user_id']
try:
group_i = db.DBSession.query(AttrGroup).filter(AttrGroup.id==group_id).one()
group_i.project.check_write_permission(user_id)
... |
Get all the group items in a network
def get_network_attributegroup_items(network_id, **kwargs):
"""
Get all the group items in a network
"""
user_id=kwargs.get('user_id')
net_i = _get_network(network_id)
net_i.check_read_permission(user_id)
group_items_i = db.DBSession.query(AttrG... |
Get all the items in a specified group, within a network
def get_group_attributegroup_items(network_id, group_id, **kwargs):
"""
Get all the items in a specified group, within a network
"""
user_id=kwargs.get('user_id')
network_i = _get_network(network_id)
network_i.check_read_permission(... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.