diff --git a/kadmos/graph/graph_kadmos.py b/kadmos/graph/graph_kadmos.py index c9f46558f6fa51a792ebfead93d3495c8c2ef245..2dd4e8e823b15a8eee694f65c01c36fdbe9c93b4 100644 --- a/kadmos/graph/graph_kadmos.py +++ b/kadmos/graph/graph_kadmos.py @@ -1934,6 +1934,90 @@ class KadmosGraph(nx.DiGraph, EquationMixin, VistomsMixin): data_exchange_dict}) return + def add_dc_licensing(self, dc_uid, license_type=None, license_specification=None, license_info=None): + """Method to add licensing information to a design competence + + :param dc_uid: uid of the design competence + :type dc_uid: str + :param license_type: type of the license, optional + :type license_type: str + :param license_specification: specification of the license, optional + :type license_specification: str + :param license_info: additional info about the license, optional + :type license_info: str + """ + options = ['license_type', 'license_specification', 'license_info'] + dict = {'license_type': license_type, 'license_specification': license_specification, 'license_info': license_info} + + first = True + for option in options: + if dict[option]: + if first: + self.nodes[dc_uid].update({'licensing_info': {option: dict[option]}}) + first = False + else: + self.nodes[dc_uid]['licensing_info'].update({option: dict[option]}) + return + + def add_dc_sources(self, dc_uid, repository_link=None, download_link=None, references=None): + """Method to add source information to a design competence + + :param dc_uid: uid of the design competence + :type dc_uid: str + :param repository_link: link to the dc's repository, optional + :type repository_link: str + :param download_link: link to download the dc, optional + :type download_link: str + :param references: additional info about the references, optional + :type references: str + """ + options = ['repository_link', 'download_link', 'references'] + dict = {'repository_link': repository_link, 'download_link': download_link, + 'references': references} + + first = True + for option in options: + if dict[option]: + if first: + self.nodes[dc_uid].update({'sources_info': {option: dict[option]}}) + first = False + else: + self.nodes[dc_uid]['sources_info'].update({option: dict[option]}) + return + + def add_dc_execution_details(self, dc_uid, operating_system=None, integration_platform=None, command=None, + description=None, software_requirements=None, hardware_requirements=None): + """Method to add execution details information to a design competence + + :param dc_uid: uid of the design competence + :type dc_uid: str + :param operating_system: Operating system the tool is running on (e.g. Linux, Windows, MAC OS), optional + :type operating_system: str + :param integration_platform: Specification of the integration platform (e.g. RCE, Optimus), optional + :type integration_platform: str + :param command: Execution command (e.g. runTool.exe), optional + :type command: str + :param description: Additional infos of the execution, optional + :type description: str + :param software_requirements: Requirements on the software side, optional + :type software_requirements: str + :param hardware_requirements: Requirements on the hardware side, optional + :type hardware_requirements: str + """ + options = ['operating_system', 'integration_platform', 'command', 'description', 'software_requirements', 'hardware_requirements'] + dict = {'operating_system': operating_system, 'integration_platform': integration_platform, + 'command': command, 'description': description, 'software_requirements': software_requirements, 'hardware_requirements': hardware_requirements} + + first = True + for option in options: + if dict[option]: + if first: + self.nodes[dc_uid].update({'execution_details': {option: dict[option]}}) + first = False + else: + self.nodes[dc_uid]['execution_details'].update({option: dict[option]}) + return + def add_node(self, n, attr_dict=None, **attr): """Add a single node and update node attributes. diff --git a/kadmos/graph/mixin_vistoms.py b/kadmos/graph/mixin_vistoms.py index 7dcd3bafa5988f08609dcab5c5eea2917f56f46b..bb7ed4f6c4b33222d6880f78be60eff50a7109e7 100644 --- a/kadmos/graph/mixin_vistoms.py +++ b/kadmos/graph/mixin_vistoms.py @@ -717,7 +717,7 @@ class VistomsMixin(object): block_type = 'postcouplinganalysis' else: block_type = 'rcganalysis' - block_metadata = self.get_function_metadata(block) + block_metadata = self.nodes[block] else: raise Exception('Block category %s not supported.' % self.nodes[block]['category']) else: diff --git a/kadmos/vistoms/templates/VISTOMS.html b/kadmos/vistoms/templates/VISTOMS.html index 4b5a4c80f78709d96321fab743879b74d3aebc9d..05d42f08ca36bc7ee854dcbbef8c63c2e96da63b 100644 --- a/kadmos/vistoms/templates/VISTOMS.html +++ b/kadmos/vistoms/templates/VISTOMS.html @@ -19776,17 +19776,6 @@ //menu --> functions for right click options (coordinator) var toolMenuCoor = [ - { - title: 'Show competence info', - onMouseDown: function(elm, k, i) { - showToolTable(k); - }, - onMouseUp: function(elm, k, i) { - }, - onMouseOver: function(elm, d, i) { - }, - childrenItems: [] - }, { title: 'Show input variable tree...', onMouseDown: function(elm, k, i) { @@ -19833,9 +19822,9 @@ //menu --> functions for right click options for other tools var toolMenuSpecial = [ { - title: 'Add metadata', + title: 'Competence information', onMouseDown: function(elm, k, i) { - addDCMetadata(data,currentGraph,k) + editDCMetadata(data,currentGraph,k) //sendDCMetadata(dc_metadata); }, onMouseUp: function(elm, k, i) { @@ -20347,7 +20336,7 @@ }); } - function addDCMetadata(theData, theCurrentGraph, aNode=null) + function editDCMetadata(theData, theCurrentGraph, aNode=null) { bootbox.hideAll(); @@ -20355,7 +20344,7 @@ if (aNode != null) { metadata = aNode.metadata; - } + } var html = d3.select("html") var form_content = html.append("div").attr("class","form-content").attr("style","display:none") @@ -20367,18 +20356,58 @@ form_group.append("label").text("General information") form_group = form.append("div").attr("class","form-group") form_group.append("text").text("Description") - input = form_group.append("textarea") + var description = form_group.append("textarea") .attr("id","description") .attr("class","form-control") .attr("name","description") .attr("placeholder","Add a description for the DC here") + if (typeof metadata.general_info != "undefined" && metadata.general_info !=null && typeof metadata.general_info.description!="undefined") + { + description.attr("value",metadata.general_info.description) + } + + form_group = form.append("div").attr("class","form-group") + form_group.append("text").text("Mode") + var mode = form_group.append("input") + .attr("id","mode") + .attr("class","form-control") + .attr("name","mode") + .attr("placeholder","Mode (e.g. main)") + if (metadata.mode) + { + mode.attr("value",metadata.mode) + } + + form_group = form.append("div").attr("class","form-group") + form_group.append("text").text("Version") + var version = form_group.append("input") + .attr("id","version") + .attr("class","form-control") + .attr("name","version") + .attr("placeholder","Version (e.g. 1.0)") + if (metadata.version) + { + version.attr("value",metadata.version) + } + form_group = form.append("div").attr("class","form-group") form_group.append("text").text("Status") - input = form_group.append("select").attr("id","status").style("margin-left","5px") - input.append("option").attr("type","select").attr("value","-").text("Please select...") - input.append("option").attr("type","select").attr("value","Available").text("Available") - input.append("option").attr("type","select").attr("value","N/A").text("N/A") + var input = form_group.append("select").attr("id","status").style("margin-left","5px") + var status = input.append("option") + status.attr("type","select").attr("value","-").text("Please select...") + status = input.append("option") + status.attr("type","select").attr("value","Available").text("Available") + if (typeof metadata.general_info != "undefined" + && metadata.general_info !=null + && typeof metadata.general_info.status!="undefined" + && metadata.general_info.status=="Available"){status.attr("selected","true")} + status = input.append("option") + status.attr("type","select").attr("value","N/A").text("N/A") + if (typeof metadata.general_info != "undefined" + && metadata.general_info !=null + && typeof metadata.general_info.status!="undefined" + && metadata.general_info.status=="N/A"){status.attr("selected","true")}{status.attr("selected","true")} var contacts = [] if (theCurrentGraph.organization.contacts){contacts=theCurrentGraph.organization.contacts}; form_group = form.append("div").attr("class","form-group") @@ -20386,21 +20415,39 @@ input = form_group.append("select").attr("id","owner_uid").style("margin-left","5px") input.append("option").attr("type","select").attr("value","-").text("Please select...") contacts.forEach(function(contact){ - input.append("option").attr("type","select").attr("value",contact.attrib.uID).text(contact.name + " (" + contact.company + ")") + var owner = input.append("option") + owner.attr("type","select").attr("value",contact.attrib.uID).text(contact.name + " (" + contact.company + ")") + if (typeof metadata.general_info != "undefined" + && metadata.general_info !=null + && typeof metadata.general_info.owner!="undefined" + && typeof metadata.general_info.owner!=null + && contact.attrib.uID==metadata.general_info.owner.contactUID){owner.attr("selected","true")} }) form_group = form.append("div").attr("class","form-group") form_group.append("text").text("Creator") input = form_group.append("select").attr("id","creator_uid").style("margin-left","5px") input.append("option").attr("type","select").attr("value","-").text("Please select...") contacts.forEach(function(contact){ - input.append("option").attr("type","select").attr("value",contact.attrib.uID).text(contact.name + " (" + contact.company + ")") + var creator = input.append("option") + creator.attr("type","select").attr("value",contact.attrib.uID).text(contact.name + " (" + contact.company + ")") + if (typeof metadata.general_info != "undefined" + && metadata.general_info !=null + && typeof metadata.general_info.creator!="undefined" + && typeof metadata.general_info.creator!=null + && contact.attrib.uID==metadata.general_info.creator.contactUID){creator.attr("selected","true")} }) form_group = form.append("div").attr("class","form-group") form_group.append("text").text("Operator") input = form_group.append("select").attr("id","operator_uid").style("margin-left","5px") input.append("option").attr("type","select").attr("value","-").text("Please select...") contacts.forEach(function(contact){ - input.append("option").attr("type","select").attr("value",contact.attrib.uID).text(contact.name + " (" + contact.company + ")") + var operator = input.append("option") + operator.attr("type","select").attr("value",contact.attrib.uID).text(contact.name + " (" + contact.company + ")") + if (typeof metadata.general_info != "undefined" + && metadata.general_info !=null + && typeof metadata.general_info.operator!="undefined" + && typeof metadata.general_info.operator!=null + && contact.attrib.uID==metadata.general_info.operator.contactUID){operator.attr("selected","true")} }) @@ -20495,12 +20542,12 @@ var modal = bootbox.dialog({ message: $(".form-content").html(), - title: "Add Competence Metadata", + title: "Competence Metadata: " + aNode.name, size: "large", buttons: [ { label: "Cancel", - className: "btn btn-default pull-left", + className: "btn btn-default", callback: function() { modal.modal("hide"); d3.selectAll(".form-content").remove(); @@ -20508,7 +20555,7 @@ }, { label: "OK", - className: "btn btn-primary pull-left", + className: "btn btn-primary", callback: function() { var metadata = { uID: aNode.uID, @@ -20570,14 +20617,7 @@ d3.selectAll(".form-content").remove(); } }); - - - } - - function sendDCMetadata(aMetadata) - { - - } + } var addCBButton = revertDiv.append("button") diff --git a/kadmos/vistoms/vistoms.py b/kadmos/vistoms/vistoms.py index d9ce80268c198fd4dcc681ef8928fd06fdd6468e..774865bb297872fe43f46a1367a984d68406cdd9 100644 --- a/kadmos/vistoms/vistoms.py +++ b/kadmos/vistoms/vistoms.py @@ -825,33 +825,14 @@ def kadmos_add_DC_metadata(): graph = load(os.path.join(path, graphFileName), file_check_critical=False) mpg = None - - - graph.add_dc_general_info(nodeName, - description=metadata_py['description'], - status=metadata_py['status'], - owner_uid=metadata_py['owner_uid'], - creator_uid=metadata_py['creator_uid'], - operator_uid=metadata_py['operator_uid']) - - ### Functions do not exist yet ### - ################################### - # graph.add_dc_licensing(nodeName, - # license_type=metadata_py['license_type'], - # license_specification=metadata_py['license_specification'], - # license_info=metadata_py['license_info']) - # graph.add_dc_sources(nodeName, - # repository_link=metadata_py['repository_link'], - # download_link=metadata_py['download_link'], - # references=[metadata_py['references']]) - # graph.add_dc_execution_details(nodeName, - # operating_system=metadata_py['operating_system'], - # integration_platform=metadata_py['integration_platform'], - # command=metadata_py['command'], - # description=metadata_py['description_cmd'], - # software_requirements=[metadata_py['software_requirements']], - # hardware_requirements=metadata_py['hardware_requirements'],) - ################################### + graph.add_dc_general_info(nodeName, description=metadata_py['description'], status=metadata_py['status'], + owner_uid=metadata_py['owner_uid'], creator_uid=metadata_py['creator_uid'], + operator_uid=metadata_py['operator_uid']) + graph.add_dc_performance_info(nodeName, precision=1, fidelity_level=0, run_time=10, verification=dict()) + graph.add_dc_licensing(nodeName, license_type="", license_specification="", license_info="") + graph.add_dc_sources(nodeName, repository_link="", download_link="", references="") + graph.add_dc_execution_details(nodeName, operating_system="", integration_platform="", command="", + description="", software_requirements="", hardware_requirements="") # Add the graph with the updated function order to VISTOMS newVistomsData = graph.vistoms_add_json(function_order=function_order, graph_id=graphID, mpg=mpg)