def addEntityAttribute_Float(self, objectName, property_name, property_description, minimum, maximum): #New float attribute if (project.getAttributeIdThroughName( objectName, property_name) == "error"): #attribute does not exist if ( project.getEntityIdThroughName(objectName) != "error" ): #if object exists #will get object currently selected in comboBox objectId = project.getEntityIdThroughName( objectName) #get object id project.addEntityAttribute(id=objectId, name=property_name, aType="Float", interface="textbox (default)", description=property_description, labels=[minimum, maximum]) if (objectName == self._currentEntitySelected ): #if the object is currently selected object = project.getEntityById(objectId) attrib = object.attributes[-1] msg = QVariant([ attrib.name, attrib.type, attrib.interface, str(attrib.description) ]) QMetaObject.invokeMethod(self.object, "appendPropertiesModel", Q_ARG(QVariant, msg)) else: QMetaObject.invokeMethod( self.object, "attributeExistsError" ) #will be invoked if attribute with the same name exists --JAVASCRIPT FUNCTION
def addEntityAttribute_String(self, objectName, property_name, property_description, property_interface, plabels): #add a string attribute if (project.getAttributeIdThroughName( objectName, property_name) == "error"): #attribute does not exist if (project.getEntityIdThroughName(objectName) != "error"): #if object exists objectId = project.getEntityIdThroughName( objectName) #get object id project.addEntityAttribute(id=objectId, name=property_name, aType="String", interface=property_interface, description=property_description, labels=plabels) if (objectName == self._currentEntitySelected ): #if the object is currently selected object = project.getEntityById(objectId) attrib = object.attributes[-1] msg = QVariant([ attrib.name, attrib.type, attrib.interface, str(attrib.description) ]) QMetaObject.invokeMethod(self.object, "appendPropertiesModel", Q_ARG(QVariant, msg)) else: QMetaObject.invokeMethod(self.object, "attributeExistsError")
def renameSelectedObject( self, objectName, newObjectName ): #This function Renames an object ---HANDLE OBJECT RENAME if (newObjectName != objectName): #if object name is not empty if (project.getEntityIdThroughName(objectName) != "error"): #if object exists if (project.getEntityIdThroughName(newObjectName) == "error" ): #if object with a similiar name does not exist obj = project.EditEntity( project.getEntityIdThroughName(objectName)) obj.name(newObjectName) index = project.getEntityNames().index( newObjectName) #get index arg1 = QVariant(index) arg2 = QVariant(newObjectName) msg = QVariant([arg1, arg2]) QMetaObject.invokeMethod( self.object, "setObjectModel", Q_ARG( QVariant, msg)) #---invoke JAVASCRIPT METHOD to update Model if (self._currentEntitySelected == objectName ): #if current entity selected has the old object name self._currentEntitySelected = newObjectName #update entity to new name else: #if object with similar name exists QMetaObject.invokeMethod( self.object, "objectNameError" ) #if object name exists invoke objectNameError dialog
def visualizeSelectedObject(self, objectName): if (project.getEntityIdThroughName(objectName) != "error"): #if object exists if (project.getEntityAttributeCount( project.getEntityIdThroughName(objectName)) > 0): #at least one attribute is associated with entity msg = project.generateFakeForm( project.getEntityIdThroughName(objectName)) QMetaObject.invokeMethod(self.object, "renderObjectDialog", Q_ARG(QVariant, msg))
def createOneToMany(self, object1_name, object2_name): #invoke one to one relationship dialog object1 = project.getEntityIdThroughName(object1_name) object2 = project.getEntityIdThroughName(object2_name) if (project.addRelationship("one to many", object1, object2) != "relationship exists"): #create relationship pass #success else: QMetaObject.invokeMethod( self.object, "relationshipExistsError") #relationship exists error
def deleteSelectedObject( self, objectName): #delete the selected objects --HANDLE OBJECT DELETION if (project.getEntityIdThroughName(objectName) != "error"): if (self._currentEntitySelected == objectName ): #if the currently selected object name==(Entity.name) QMetaObject.invokeMethod(self.object, "cleanPropertiesModel") self._currentEntitySelected = None #set current entity selection to None msg = QVariant(project.getEntityNames().index( objectName)) #get index of entity using name QMetaObject.invokeMethod(self.object, "removeObjectItem", Q_ARG(QVariant, msg)) #remove from listview project.EditEntity(project.getEntityIdThroughName( objectName)).delete() #delete object in database
def triggerPropertyTableDisplay(self): #ACTIVATED WHEN OBJECT IS SELECTED object = project.getEntityById( project.getEntityIdThroughName( self._currentEntitySelected)) #get object id through selected QMetaObject.invokeMethod(self.object, "cleanPropertiesModel") #will clear the propertiesModel for i in object.attributes: #get attributes associated with model msg = QVariant([i.name, i.type, i.interface, str(i.description) ]) #append to model attribute by attribute QMetaObject.invokeMethod(self.object, "appendPropertiesModel", Q_ARG(QVariant, msg))
def addEntity(self, name, description): #create a new entity/object if (project.getEntityIdThroughName(name) == "error" ): #will return error if name does not exist project.addEntity(name=name, description=description) print(project.getEntities()) msg = QVariant(name) QMetaObject.invokeMethod(self.object, "addObjectModel", Q_ARG(QVariant, msg)) #adds to the object model print(self._currentEntitySelected) else: QMetaObject.invokeMethod( self.object, "objectNameError" ) #if object name exists invoke objectNameError dialog