I'm trying to make OrientDB Studio display a string as a label for each node, like in this screenshot from Susheel Kumar
But when I run Susheel's code (posted below for posterity), the nodes all appear labelled by their #rid fields instead, like this screenshot:
Question: Is there an automated way to display all these labels?
I can tell an individual node to display its "name" field as a label by clicking (1) the node, (2) the "eye" symbol, (3) the settings symbol, and selecting "name" from the dropdown menu, but this will be impossible to do when I have a large number of nodes. This seems like the sort of thing you'd do when defining the "Person" node class, but I see no indication of this this in Susheel's code (posted below), and I haven't been able to reach him.
And for my application, the visualization is essentially useless if I can't visualize node labels, so any help would be much appreciated :)
Below is the code I took from Susheel's Introduction to OrientDB to produce my screenshot above:
-- Create a class Person and add two properties lastName & firstName using below commands
create class Person extends V;
create property Person.lastName string;
create property Person.firstName string;
-- Create a class Employee which extends from Person & add few properties to it
create class Employee extends Person;
create property Employee.empno integer;
create property Employee.sal integer;
-- Create a class Department extends from V
create class Department extends V;
create property Department.deptno integer;
create property Department.name string;
-- If you noticed we used Inheritance above when creating Employee class by extending it from Person. That's a cool feature!!! Now we have classes to represent vertex (a document) & let's create a class to represent Edge to establish the relationship.
create class WorksAt extends E;
-- So now we are all set to add/create data to graph model we create above.
-- Let's create some employees (vertex or document)
create vertex Employee set empno=101,firstName='John',lastName='Jacob',sal=5000;
create vertex Employee set empno=102,firstName='Adam',lastName='Bill',sal=7000;
create vertex Employee set empno=103,firstName='David',lastName='Manon',sal=4000;
-- Similarly lets create some departments
create vertex Department set deptno=10,name='Accounts';
create vertex Department set deptno=20,name='HR';
create vertex Department set deptno=20,name='IT';
-- Now time to establish relationship. Create some Edges
create Edge WorksAt from #12:0 to #13:1;
create Edge WorksAt from #12:1 to #13:0;
create Edge WorksAt from #12:2 to #13:2;
-- Show all employees
select * from Employee;
This is a preference setting that can be easily changed, for each class. You can display the current display settings by issuing the following query (in Browse tab) :
select * from _studio
If there are no records, simply follow the procedure you have described before (click on the node, click the "eye" symbol, than change the "display" property). When you are done, simply click "Save Configuration".
Now the previous query should display a JSON object of type GraphConfig that you can edit. There are a lot of parameters that you can change, such as nodes width, color, icon, radius and display which is the option you are looking for.
You can verify that the configuration has been saved by running the query that #cheseaux contributed (select * from _studio)
Also, make sure you click save configuration both in the vertex view (when you are changing the label), and also in the main graph view of OrientDB studio.
For example, when i run it on my db after changing the label ("display":"hash"), here's what i get:
{"width":1770,"height":500,"classes":{"psswd":{"fill":"#d62728","stroke":"#951b1c","icon":null,"display":"hash"}},"node":{"r":30},"linkDistance":140,"charge":-1000,"friction":0.9,"gravity":0.1}
Related
I want to describe a self reference relation in a Liferay entity. Is there a recommended way to do this ?
I want to do this in order to describe a hierarchy.
At the moment, I just added a new column which I called "parentId" and I will save there the ID of the row that will be the parent of this one. If I use the "Diagram view", from within eclipse, if I draw a self reference relationship it adds a new row that duplicated the name of the ID: for example, suppose I want to describe an employee hierarchy - I have an Employee entity on which I add the default fields; one of these fields is the employeeId field which will be also the primary key. Now, if I draw a self reference relationship, the IDE will add another field entry that will be named the same way (eg. employeeId)
There is no official recommended way to do it, as you will have to add your own logic in your code to handle it.
In case you want to follow the convention used in Liferay code, Liferay code usually represents the hierarchy using a column called parent<primaryKey> and sometimes an auxiliary column called treePath to store the hierarchy path of the element, see:
https://github.com/search?q=repo%3Aliferay%2Fliferay-portal+filename%3Aservice.xml+parent&type=Code
https://github.com/search?q=repo%3Aliferay%2Fliferay-portal+filename%3Aservice.xml+treePath&type=Code
About the treePath column, service builder will add to the java class some methods (buildTreePath and updateTreePath) that will help to populate it, see the service builder templates: https://github.com/liferay/liferay-portal/blob/11e6081f96abb6bf299369519434c1eafa0658e3/modules/util/portal-tools-service-builder/src/main/resources/com/liferay/portal/tools/service/builder/dependencies/extended_model_base_impl.ftl#L65-L115
This column makes easier to get all the parent elements of the hierarchy, just split it by the / char and you will get all the primary keys of the ancestors.
I have an element which is created as a table. In the "Element Properties" window, I see the Type is Class and Stereotype is table. For other similar tables, the Type is Table and Stereotype is table. Something seems to be icky with this particular instance.
However, when I run the following script
var element as EA.Element;
element = Repository.GetTreeSelectedObject();
Session.Output(element.Type);
The result is (for both tables!) Class. I thought to outsmart the EA UI by programmatically setting the type, but as both tables (the OK table and the "broken" table) both produce Class when asked for the .Type, I'm hesitant to set the .Type using a script.
I have thought about removing this table and re-adding a new one, but this is tedious as the table has a lot of connections.
How to change the Type of this particular "broken" table to "Table"?
The problem is that both «table» stereotypes are not the same.
The one where the type indicates Table is the correct one.
The other one is a rogue one.
Steps to solve this:
Remove the rogue stereotype from the internal stereotype list Configure | Reference Data | UML Types (to prevent the problem from happening again)
Change the stereotype from the problematic element to the stereotype «table» from the UML profile EAUML. In a script you can do this by setting the property EA.Element.StereotypeEx to the qualified name: EAUML::table). Manually you can use the [...] button to select the correct stereotype from the correct profile.
Is there a way to add an edge between existing vertices which maps one common property between them ?
Example -
Class1 has three properties - A,B,C
and
Class 2 has three properties - A,D,E
where Class1.A has same values as that in Class2.A
How can I create an edge which maps all A values in Class1 to all A values in Class2 without reloading the data ?
Also, is there a way I can achieve this from the User Interface ?
I can see an option to create an Edge there but it does not ask for the property value to map with.
Note: I am using orientdb-community-importers-2.2.27
Thanks!
Try this:
create edge <edge name> from (select from class1 where A IN (select A from class2)) to (select from class2 where A IN (select A from class1))
Hope it helps
Regards
I am experimenting with a Web API 2 project in Visual Studio 2012. I used the code first from existing DB option with EF6 to select one table and one view. I then tried to create a controller for the simple table using the profile for Web API 2 OData. The scaffolding of the controller fails telling me that "the item with identity 'Client Last Reveiwed On' already exists in the metadata collection". The problem is not only am I sure that field is unique for this project but that field is part of the view and not the table. Below is the model generated for the simple table (t_Client) that I was trying to create the controller for. As you can see the offending column is not part of the class. I will add below the definition for the column that VS/EF doesn't like which is in the class for the view.
Any ideas why this won't work?
Partial Public Class t_Client
<Key>
<DatabaseGenerated(DatabaseGeneratedOption.None)>
Public Property ClientID As Integer
<Required>
<StringLength(255)>
Public Property ClientName As String
Public Property isActive As Boolean
End Class
Here is the column that is defined in a separate view.
<Column("Client Last Reviewed On", TypeName:="date")>
Public Property Client_Last_Reviewed_On As Date?
I am not sure which of these steps fixed the issue but here are some notes on the topic.
Removing references to the model based on the SQL view eliminated errors.
I went into SQL and updated the view to contain a row number column.
Even with the row number column, EF tagged multiple columns as the key.
I manually edited the model to make the row number column the key.
I also had to update a cast the data type of a few columns in the SQL view to match reality, mainly bigint that was really just integer.
My guess is the fix was the well defined key.
I am using Breeze (http://www.breezejs.com/) and to use the functionality I want it requires mapping to a complete entity and all of its fields. I have a "Person" entity, but it includes a Social Security Number field. I want to keep this SSN# field private so I would like to create an entity named SubSetPerson that is updateable, has navigation properties and only contains the columns I want (e.g. ID, FirstName, LastName, myNavigationProperty) and does not contain the SSN#. I am using database/model first. Is this possible?
If you are using database first, then you could create a view for that table which only selects the columns you want. Then update the EF model browser to include that view.
Try using a Master-Detail type structure for your person. The master table would contain the person's public information; ie name, birthdate, etc... The detail table would contain only the more sensitive information (SSN, etc...). Then depending on your needs you can load the detail or not.