Can edges have Set of properties (by set i mean multi valued atributes) - orientdb

Suppose i have a two vertexes A and B.
Can the edge between this vertices have Set of properties. By Set i mean Set. Not a map of key values.
EG Edge from A to B has Set tags.
I want model someting like A workswith B
Now workswith has properties likes ondays [monday,tuesday,friday]
tags values = ['Monday','Tuesday','Friday'];
Here tags is a single propery but its type is Set.Is it possible?
Now will traversing i would like to find something like
Find with all A works on monday?
Find will all A works on an day?
Note :This is a simple example depicting my use case .My real use case is more complex.

Yes you can. An edge is a document so can be very very complex with collections, maps and nested documents.

Related

How do I refer the shape's data from sub-shape of Visio custom shape

I'm trying to design a custom shape in Visio.
My structure is like this:
In the "Edit Master" page I have some rectangles, I called my shape "MyDay", so that's its document's name in the Master Explorer and in the edit window.
My problem is, that I can't find a way to refer the shape's date itself (like =MyDay!Name() or =MyDay!User.MyUserField) from one of my sub-shapes.
If I add a reference to ThePage and drop the master on a page - I adds that property to the page itself - again - no reference to the main shape from its sub-shapes.
I know there is no "Parent" property in ShapeSheet formulas (only on VBA), but I'm really trying to find a way to refer it using fields or formulas, without the need to write and run VBA code.
Many appreciations for any help!
Paul is correct, but I will add that it is normally expected that a Master contains only one shape, but that can be a group shape that contains other shapes. Therefore, a formula in a sub-shape can refer to any shape in that group, including the top level group shape, using the Sheet.n syntax. When an instance of the master shape is dropped onto a page, then Visio will automatically update the n ID to the actual shape ID in the page. The shape ID has to be unique within the shapes collection that it is part of, so the top-level group shape needs to be assigned a new unique ID, but the sub-shapes do not because they already have an ID that is unique within the shapes collection that they are part of.
You need to find the parent shape's Sheet reference number (select it and then ribbon Developer -> Shape Name -> Shape). This will be something like Sheet.6.
Use this reference in your formula e.g.
Sheet.6!User.MyUserField

Working with elements "diagram properties" in script

I have an my own MDG, consist of several elements. I need change view of those elements when its placed at different diagram. There is a mechanism called "user-selected settings" in MDG and I use its to change view of elements (e.g. via shape script function "HasProp" ). But for several reason I need to change diagram property for element via script. Are there any way to work with diagram property for element within script ?
It's possible but a bit tricky. First of all you need to get hold of the right diagram's table data stored in t_diagram. Issue a SQL like
SELECT StyleEx FROM t_diagram WHERE Diagram_ID = <theID>
Of course <theID> must be the diagram id of the diagram. Now you can use some string operations. Here's what my test diagram brought:
ExcludeRTF=0;DocAll=0;HideQuals=0;AttPkg=1;ShowTests=0;ShowMaint=0;SuppressFOC=1;MatrixActive=0;SwimlanesActive=1;KanbanActive=0;MatrixLineWidth=1;MatrixLineClr=0;MatrixLocked=0;TConnectorNotation=UML 2.1;TExplicitNavigability=0;AdvancedElementProps=1;AdvancedFeatureProps=1;AdvancedConnectorProps=1;m_bElementClassifier=1;ProfileData=;MDGDgm=VW VA Functional 3::Use case activity;STBLDgm=;ShowNotes=0;OPTIONS_9CEFE070=Structure=1:;VisibleAttributeDetail=0;ShowOpRetType=1;SuppressBrackets=0;SuppConnectorLabels=0;PrintPageHeadFoot=0;ShowAsList=0;SuppressedCompartments=;Theme=:119;SaveTag=79E21B13;;
which is a CSV at its best. See the
OPTIONS_9CEFE070=Structure=1:;
which actually encodes the diagram properties. Here it's just one with the name Structure and its value is set to 1. The 9CEFE070 refers to the GUID the diagram object. Of course not directly.
So find the diagram objects of the diagram itself with
SELECT Object_ID, ObjectStyle FROM t_diagramobjects
The Object_ID is for identifying the object behind (you might use a join to get needed information). And the ObjectStlye contains something like (from my test)
DUID=9CEFE070;HideIcon=0;
And there you have that hex string. Now you know that this one object has a diagram property set.
You should issue some queries manually to get familiar with that.
Now, to set a property, you "just" have to find the DUID from the diagram object of the diagram (just use the query above). Now you can add that OPTIONS_<duid> part or in case it already exists you need to modify it with according string operations. Finally you need to update the diagram table with
Repository.Execute("UPDATE t_diagram SET StyleEx = `<new string>` WHERE diagram_id = <theID>")
Note that this is an undocumented operation and you get
a) no support and
b) can easily clobber your whole model which is
c) the reason for a).
Have a backup!

Select all Vertices with outE filters connecting to a specific list of Vertices

I'm new to ODB, but not SQL, and can't seem to find a tutorial to learn from, or a even similar q&a; but that's likely my inability to ask the question correctly.
I'm looking for a way to find all Vertices of a particular class (e.g. Claim) which have at least one specific outE class (e.g. available_to_role) and those Edges all have a particular property value (e.g. role="adj1") and those Edges also all have on their corresponding other edge a particular Vertices with a particular property value (e.g. date).
I've tried searching from both sides of the edge and from the edge in particular but it doesn't work as expected. I always get all Claims vertices connected with any one date of a list of more than one date, and not only the Claims that match with all dates.
This is the closest I've gotten, but it results in Claims returned that are only available on one of the two dates, I'm not sure how to force an && result to only get claims available on all dates provided.
SELECT
*,
out.label as claim_label,
in.date as date,
count(in.date)
FROM
available_to_role
WHERE
role='adj1'
AND
in.date in ['2018-06-02 00:00:00','2018-06-03 00:00:00']
GROUP BY
in.date
I'm looking for a way to get all Claims that are available to a particular role on all the dates supplied, not just one of the dates supplied. And, I need those results as individual responses, not aggregated (e.g. ["role","role"] ["date","date"]). In all case, I know the dates and roles, but not the Claims.
Any help would be greatly appreciated.
I'm not sure to have undertood correctly but:
try this:
select from Claims where outE("available_to_role").role contains "adj1" and out("available_to_role").date in ['2018-06-02 00:00:00','2018-06-03 00:00:00']
if you want to make sure that the vertex in Claims class match both dates you have to use AND condition for both dates
Hope it helps
Regards

Add multiple properties during edge creation in gremlin

I have used this query
g.V().has('empId','123').as('a').V().has('deptId','567').addE('worksAt').properties('startedOn','17/15/07','title','manager','pay',15000)
which doesn't work.
Adding a single property works with a .property step
g.V().has('empId','123').as('a').V().has('deptId','567').addE('worksAt').property('startedOn','17/15/07')
Instead of specifying all properties in one property-step, you can simply concatenate multiple property-steps:
g.V().has('empId','123').as('a').V().has('deptId','567').addE('worksAt').
property('startedOn','17/15/07').property('title','manager').property('pay',15000)
Your query doesn't specify which vertices should be connected by the edge. When you want the edge to go out from the vertex with the empId 123, then you have to insert a from:
g.V().has('empId','123').as('a').V().has('deptId','567').addE('worksAt').from('a').
property('startedOn','17/15/07').property('title','manager').property('pay',15000)
See the addEdge-step for more information.

Tag hierarchies and handling of

This is a real issue that applies on tagging items in general (and yes, this applies to StackOverflow too, and no, it is not a question about StackOverflow).
The whole tagging issue helps cluster similar items, whatever items they may be (jokes, blog posts, so questions etc). However, there (usually but not strictly) is a hierarchy of tags, meaning that some tags imply other tags too. To use a familiar example, the "c#" so tag implies also ".net"; another example, in a jokes database, a "blondes" tag implies the "derisive" tag, similarly to "irish" or "belge" or "canadian" etc depending on the joke's country origin.
How have you handled this, if you have, in your projects? I will supply an answer describing two different methods I have used in two separate cases (actually, the same mechanism but implemented in two different environments), but I am also interested not only on similar mechanisms, but also on your opinion on the hierarchy issue.
This is a tough question. The two extremes are an ontology (everything is hierarchical) and a folksonomy (tags have no hierarchy). I have answered this on WikiAnswers, with a reference to Clay Shirky's "Ontology is Overrated" article which claims you should set no hierarchy.
Actually I would say that it is not so much a hierarchical system but a semantic net with felt distancies between tags meanings. What do I mean: mathematics is closer to experimental physics then to gardening.
Possibility to build such a net: Build pairs of tags and let people judge the perceived distance (using a measure like 1-10, meaning something like [synonyms, alike,...,antonyms], ...) and when searching, search for all tags within a certain distance.
Does a measure have to be equal distance if coming from the oposite direction ([a,b] close -> [b,a,] close)? Or does proximity imply [a,b] close and [b,c] close -> [a,b] close?
Maybe the first word will by default trigger another semantic field? If you start at "social worker", "analyst" ist near. If you start at "programmer", "analyst" is near as well. But starting at any of these points, you probably would not count the other as near ("sozial worker" is by no means close to "programmer").
You therefore would have only pairs judged and judged in both directions (in random order).
[TagRelations]
tagId integer
closeTagId integer
proximity integer
Example for selection of similar tags:
select closeTagId from TagRelations where tagId = :tagID and proximity < 3
The mechanism I have implemented was to not use the tags given themselves, but an indirect lookup table (not strictly DBMS terms) which links a tag to many implied tags (obviously, a tag is linked with itself for this to work).
In a python project, the lookup table is a dictionary keyed on tags, with values sets of tags (where tags are plain strings).
In a database project (indifferent which RDBMS engine it was), there were the following tables:
[Tags]
tagID integer primary key
tagName text
[TagRelations]
tagID integer # first part of two-field key
tagID_parent integer # second part of key
trlValue float
where the trlValue was a value in the (0, 1] space, used to give a gravity for the each linked tag; a self-to-self tag relation always carries 1.0 in the trlValue, while the rest are algorithmically calculated (it's not important how exactly). Think the example jokes database I gave; a ['blonde', 'derisive', 0.5] record would correlate to a ['pondian', 'derisive', 0.5] and therefore suggest all derisive jokes given another.