Retrieve the attributes in a UML class diagram-jointjs - jointjs

I would like to retrieve attributes and class name in UML class diagram using jointJS. Please help in this regard.

maybe you can use:
this.attr('.uml-class-name-text/text')
to get the class name and use
this.attr('.uml-class-attrs-text/text')
to retrieve attributes.
"this" is the object you selected, see below
var selected;
paper.on('cell:pointerdown', function(cellView) {
selected = cellView.model;
});

All the attributes of uml diagram is in "attribute" object, if you have created the graph then you can access it as follows:
graph.getCell("cell_id").attributes;
the cell_id is present in the id property of the graph.
Hope this helps!

Related

How to Append Acumatica DAC attribute [PXEmailSource]

I want to know the best way to append the DAC attributes..Please note I need Appending method for DAC Attributes not DAC Field Attributes.
Specifically I need to append [PXEMailSource] to some of the existing DACs
Eg: PX.Objects.IN.INRegister
What is the best way to do it ...?
Any helps regarding this will be highly appreciated
You can change the attribute of the DAC using PXSubstituteAttribute
Note from Acumatica Framework Development Guide(page 95)
PXSubstitute Attribute
Indicates that the derived DAC should replace its base DACs in a specific graph or all graphs.
• public Type GraphType
Gets or sets the specific graph in which the derived DAC replaces base DACs.
• public Type ParentType
Gets or sets the base DAC type up to which all types in the inheritance
hierarchy are substituted with the derived DAC. By default, the property
has the null value, which means that all base DACs are substituted with the
derived DAC
Remarks
The attribute is placed on the definition of a DAC that is
derived from another DAC. The attribute is used primarily to make the
declarative references of the base DAC in definitions of calculations
and links from child objects to parent objects be interpreted as the
references of the derived DAC.
Below is the example how to use Attribute on INRegister DAC.
[PXPrimaryGraph(new Type[]
{
typeof(INReceiptEntry),
typeof(INIssueEntry),
typeof(INTransferEntry),
typeof(INAdjustmentEntry),
typeof(KitAssemblyEntry),
typeof(KitAssemblyEntry)
}, new Type[]
{
typeof(Where<INRegister.docType, Equal<INDocType.receipt>>),
typeof(Where<INRegister.docType, Equal<INDocType.issue>>),
typeof(Where<INRegister.docType, Equal<INDocType.transfer>>),
typeof(Where<INRegister.docType, Equal<INDocType.adjustment>>),
typeof(Select<INKitRegister, Where<INKitRegister.docType, Equal<INDocType.production>, And<INKitRegister.refNbr, Equal<Current<INRegister.refNbr>>>>>),
typeof(Select<INKitRegister, Where<INKitRegister.docType, Equal<INDocType.disassembly>, And<INKitRegister.refNbr, Equal<Current<INRegister.refNbr>>>>>)
})]
[INRegisterCacheName("Receipt")]
[Serializable]
[PXSubstitute(GraphType = typeof(REQUIREDGRAPH_WHERE_SHOULD_BE_SUBSTITED))]
[PXEMailSource]
public class INRegisterExt: INRegister
{
//...
}

UML class diagram dependency or association

I'm not really sure about how to distinguish whether I should define a relationship as dependency or association for certain cases.
For example,
class AttendanceSheet {
Map<String> students;
boolean[] attend;
public void addStudent(Student s)
{
students.add(s.getName(),s.getStudentNumber());
}
public void checkAttendance(String name) { //... }
}
class Student {
private String name;
private int staffNumber;
//more information such as address, age, etc..
Student(String n, int sn)
{
name = n;
studentNumber = sn;
}
public String getName()
{
return name.clone();
}
public String getStudentNumber()
{
return studentNumber;
}
}
For this case, would Student and Association have association or dependency?
This is because I'm not sure whether the association must have the actual reference of the object or it suffice to just have certain information that can reach the object (since student id and number is far more enough to know find out which student object it is directing to).
In your case the <<uses>> is sufficient, because you don't have actual properties of type Student in AttendanceSheet.
As a side note: not using object references and instead just having the studentNumber is - to say the least - an odd design. But I don't know the context.
On the business level those objects are related, but there is no single preferred method of diagramming this relationship.
Please see Section 9.5.4 of UML specification for more details on the topic, especially Figure 9.12
To be specific those two notations are semantically equivalent (I'm ignoring irrelevant details):
In the first one to keep a traceability you can use an explicit Dependency pretty much the way you did.
One can also consider students as a Shared Aggregation, however it might be also considered an overkill. Not necessary, just showing a possibility for an answer completeness.
You may also consider Qulified associations to indicate a reference to the Student is based on their specific properties. This is pretty much closest to your need. Sorry, I don't know how to achieve such notation in my tool, but you can find more details in Figure 11.37 in Section 11.5 of the aforementioned specification.

In Groovy what's the difference between an instance's metaClass and its class's metaClass

See the following code:
class Car implements GroovyInterceptable{}
car=new Car()
Car.metaClass.hello={println "class Car:hello"}
car.metaClass==Car.metaClass
the result is:
false
So my question is: What's the difference between car.metaClass and Car.metaClass? I did some searching, but no result. Could anyone help on this?
car.metaClass is applicable to the object called car. You may modifiy it, but it will not be visible to other Car objects
When you modify Car.metaClass, that is will be applicable to all objects of Car.class (created after this new meta modification)
class Car implements GroovyInterceptable{}
car=new Car()
Car.metaClass.accelerate {->println "Factory tested. Safe acceleration"}
car.metaClass.accelerate {->println "Owner modified : Random acceleration"}
def anotherCar= new Car();
anotherCar.accelerate()
car.accelerate()
Output
Factory tested. Safe acceleration
Owner modified : Random acceleration

Yii2 : Getting class name from relation attribute

I went through all API documentation of Yii 2.0 to find a way to reverse back to relation class name from a model attribute.
let us suppose that class Customer has a relation
$this->hasOne(Country::className(), ['id' => 'countryId']);
and in a controller function the parameter was the attribute "countryId". How is it possible to detect the class name for the related model
Get the name of the class by removing Id from the end of the variable and capitalize it. But I cannot image any situation where this would be a normal development practice. You can also define am array to make this translation for the model.
You can try to use http://php.net/manual/en/intro.reflection.php to get the names of all the functions and try to guess the name of the relation / model based on the name of the field. If you name your classes and relation fields in a proper name then you should be able to try to again guess the model.
This still feels like a hack, create a function that returns the name of the model based on the field... easiest solution. I know you try to be lazy but this is a hacky way of programming.
I'm not very clear on what data you have to start with here. If you only have a column countryId I am not sure. But say you have the relation name 'country' and the following code in your Customer model:
public function getCountry()
{
return $this->hasOne(Country::className(), ['id' => 'countryId']);
}
This is what I would do:
$relationName = 'country';
$customer = new Customer;
$relation = $customer->getRelation($relationName);
$relationModelClass = $relation->modelClass;
You could look at \yii\db\ActiveQuery::joinWithRelations() for how they do it.

Access detail element of a collection inside a section in openxava

How can I access the details element of a collection entity which is inside one section of another entity with openxava? For example, in the view of entity A, we have section {S1,S2,S3} and inside section S3 view, we have {collection of entity B}. Now I want to access the detail element of entity B, so that i can fill the element in an action controller. How do I do that?
Get the collection directly from the view, in this way:
Collection myCollection = getView().getSubview("myCollection").getCollectionObjects();
It must work even with oldest OpenXava versions
Obtain the entity associated to the view and get the collection from it. Since OpenXava 4.3 you can do it in this way:
MyEntity myEntity = (MyEntity) getView().getEntity();
Collection myCollection = myEntity.getMyCollection();
If you're using an OX previous to 4.3 do it in this way:
Map keyValues = getView().getKeyValuesWithValue();
if (!keyValues.isEmpty()) {
MyEntity myEntity = (MyEntity)
MapFacade.findEntity(getView().getModelName(), keyValues);
Collection myCollection = myEntity.getMyCollection();
}
You can do it in several ways. Here you have one, I have used it with some references that I want to modify from inside of an action called by the base module (which should work with your collection):
Query q = XPersistence.getManager().createQuery("JPQL QUERY TO RETRIVE THE COLLECTION WITH :parameterIfNeeded");
q.setParameter("parameterIfNeeded", "value");
List entityBList = q.getResultList();
if (getView().getModelName().equalsIgnoreCase("yourBaseModelViewName")) {
getView().getSubview("yourSubViewName").setModel(entityBList);
getView().getSubview("yourSubViewName").refresh();
}
You must to be using OX 4.6 to be able to use setModel(). And remember that the "yourSubViewName" is the name of the property for your collection into the base model.
I have not tested that code with a collection, so make the adjustments according to your needs, maybe you will need to CAST the query result list or something.

Resources