Hi Irene,

It's the latter case. I am only interested in my system and continuing to 
increment the ID only in my system. We are not interested in the other 
system at all. Do you have any tips how to implement your suggestion i.e. 
storing the max ID from the other system and incrementing from this number?

Br,
Maja

torsdag 18. mars 2021 kl. 17:25:05 UTC+1 skrev Irene Polikoff:

> I am confused:
>
>
>    - You are creating new instances
>    - Is this other system also continues to add new instances or is its 
>    set of instances complete?
>
>
> In the former case:
>
> When a new instance is created in this other system, how does it know that 
> you already created *Animal10254* and gave it autoincrementID == 960? 
>
> It would seem that when the other system creates a new animal, it could be 
> a different animal from the one you created. Yet, they will both have the 
> same autoincrementID. Further, if you rely on querying this other system 
> for the max autoincrementID, when you create another animal, after creating 
> *Animal10254 *and you query the other system, it may not have added a new 
> animal yet and it would again return 959 as the last id used.
>
> In other words, if you have 2 systems that add new instances and you want 
> them to use a common id counter, you need to have a common component for 
> assigning it. There should be a service you could access that will give you 
> the next available autoincrementID. And this other system should use the 
> same service so that when it creates a new animal, it knows that you 
> already used 960.
>
> Provided that such service is available, you need to call it from EDG to 
> get the autoincrementID.
>
>
> In the latter case:
>
> If all instances in the other system are already created and only you are 
> adding new instances, then you could just store the max ID from the other 
> system and can increment from this number.
>
>
> On Mar 18, 2021, at 12:07 PM, majaCap <[email protected]> wrote:
>
> Thank you all for support. I will try to explain it clearer. The  
> autoincrementID is a property that will refer to another system - and it 
> will be  an ID in another system, therefore this is not a count of current 
> instances. So there is an existing system that has some Animal instances 
> and each of Animal has this autoincrementID property. Now I built another 
> system also with Animals but containing  much more properties that I want 
> to connect to the first system based on this autoincrementID property. 
> Therefore whenever I add a new Animal to my data graph I also need to add 
> the autoincrementID continuing the id count from another system. So let's 
> say that I add to my data graph an Animal which will have URI 
> *Animal10254 * and the last value of autoincrementID from another system 
> is 959. Then my *Animal10254* needs to have autoincrementID == 960. Does 
> this makes  more sense?
>
> Kind regards,
> Maja
>
> torsdag 18. mars 2021 kl. 14:47:44 UTC+1 skrev Irene Polikoff:
>
>> Yes, a good point David.
>>
>> On Mar 18, 2021, at 8:56 AM, David Price <[email protected]> wrote:
>>
>>
>>
>> On 17 Mar 2021, at 21:56, Irene Polikoff <[email protected]> wrote:
>>
>> Another approach is to use a property value rule to automatically 
>> calculate the *autoIncrementID*
>>
>> It sounds like you want to get a count of all instances plus some number.
>>
>>
>> Hi Maja,
>>
>> I’m not sure the above is what you mean by “I would like to increment 
>> that property each time a new instance of a class is created, starting from 
>> a particular number”. 
>>
>> Either way, everyone should take care to understand the difference 
>> between "max of existing value" vs. "count of instances” logic. There is no 
>> difference in some scenarios, but they are not identical if your scenario 
>> allows people to delete instances. 
>>
>> Example: 
>>
>> Create 10 instances - the next Create integer would be 11 if no other 
>> change happens and at this moment max and count produce identical result.
>>
>> Delete 5 instances.
>>
>> Now:
>>
>> - “count instances” approach would say 6 is the next available integer
>>
>> - “max current value” approach could return anything from 6 to 11 
>> depending on exactly which instances got deleted
>>
>> Just suggesting to do a deep analysis of your reuirements before deciding 
>> which logic will work in all your user scenarios - and then do a lot of 
>> testing.
>>
>> Cheers,
>> David
>>
>>
>> What is *autoIncrementID *a property of? 
>>
>> Is it a property that each instance of a class has, so that for each 
>> instance you can get the count of ll instances of a class plus a number ? 
>>
>> Then, you would define it for the class Animal and create a property 
>> value rule as follows
>>
>>
>>
>> <PastedGraphic-65.png>
>>
>> Select Count number of inverse property values
>>
>> <PastedGraphic-67.png>
>>
>> You will get this rule if you look at the source code
>>
>> g:Animal-autoIncrementID
>>   a sh:PropertyShape ;
>>   sh:path g:autoIncrementID ;
>>   sh:datatype xsd:integer ;
>>   sh:name "autoIncrementID" ;
>>   sh:nodeKind sh:Literal ;
>>   sh:values [
>>       sh:count [
>>           sh:path [
>>               sh:inversePath rdf:type ;
>>             ] ;
>>         ] ;
>>     ] ;
>> .
>>
>> Update it because the path you want to use for the count is from an 
>> instance to the class and then from the class to all instances via inverse 
>>  i.e., rdf:type/^rdf:type
>>
>> g:Animal-autoIncrementID
>>   a sh:PropertyShape ;
>>   sh:path g:autoIncrementID ;
>>   sh:datatype xsd:integer ;
>>   sh:name "autoIncrementID" ;
>>   sh:nodeKind sh:Literal ;
>>   sh:values [
>>       sh:count [
>>           sh:path (
>>               rdf:type
>>               [
>>                 sh:inversePath rdf:type ;
>>               ]
>>             ) ;
>>         ] ;
>>     ] ;
>> .
>>
>> Now, when you access any instance of Animal, you can get a count of all 
>> Animals
>>
>> <PastedGraphic-70.png>
>>
>>
>> If you want to add some number to the count, use sparql:add function in 
>> your rule - http://datashapes.org/sparql
>>
>> You can also associate the property with the class itself, then you do 
>> not need to change the rule that will be generated by the template. 
>>
>> To associate a property with a class, switch the class hierarchy root to 
>> Resource, find owl:Class in the tree and define the property and a rule for 
>> it.
>>
>> <PastedGraphic-68.png>
>>
>> Then, you will get the generated autoIncrementID value for every class in 
>> your ontology
>>
>> <PastedGraphic-69.png>
>>
>>
>> You can also define a property for all classes to store the number you 
>> want to add to the count. The value of this property could be different for 
>> different classes.
>>
>> The above approach for adding a property to a class is for 7.0. If you 
>> are using 6.4, use the following approach to add properties directly to a 
>> class: 
>>
>>
>> https://doc.topquadrant.com/6.4/ontologies/#Customizing_Forms_for_Classes_and_Properties
>>  
>>
>> On Mar 17, 2021, at 8:49 AM, David Price <[email protected]> wrote:
>>
>> Hi Maja,
>>
>> There may be other ways, but you can do this kind of thing with an EDG 
>> Edit Rule as code. An Edit Rule can access the changes graph via a special 
>> graph called ui:addedGraph (ui:deletedGraph is also available) and find new 
>> instances being created and then search the current graph data for the max 
>> existing value and just add one. Something like this should be close and 
>> search for that property in any new instance of any class:
>>
>> property-rules:Set_autoIncrementID
>>   a teamwork:EditRule ;
>>   teamwork:ruleMayUpdate true ;
>>   ui:prototype """
>> <ui:forEach ui:resultSet=\"{#
>>         SELECT DISTINCT ?i ?class
>>         WHERE {
>>             GRAPH ui:addedGraph {
>>                 ?i a ?class .
>>                 FILTER NOT EXISTS {
>>                     ?i myschema:autoIncrementID ?currentvalue .
>>                 } .
>>             } .
>>         } }\">
>>     <ui:update ui:updateQuery=\"{!
>>             INSERT {
>>                 ?i myschema:autoIncrementID ?nextvalue .
>>             }
>>             WHERE {
>>                 GRAPH ui:addedGraph {
>>                     ?i a ?class .
>>                 } .
>>                 {
>>                     SELECT (MAX(?num) AS ?maxvalue)
>>                     WHERE {
>>                         ?noti a ?class .
>>                         ?noti myschema:autoIncrementID ?id .
>>                         BIND (ceil(xsd:decimal(?id)) AS ?num) .
>>                         FILTER bound(?num) .
>>                     }
>>                 } .
>>                 BIND (COALESCE((xsd:integer(?maxvalue) + 1), 1) AS 
>> ?nextvalue) .
>>             } }\"/>
>> </ui:forEach>
>> """^^ui:Literal ;
>>   rdfs:comment "When creating a new thing set the autoIncrementID 
>> property value to be the next highest interger value" ;
>>   rdfs:label "Default autoIncrementID" ;
>>   rdfs:subClassOf teamwork:EditRules ;
>> .
>>
>> Cheers,
>> David
>>
>>
>> On 17 Mar 2021, at 12:09, majaCap <[email protected]> wrote:
>>
>> Hi,
>>
>> I have an int property in my ontology. Now, I would like to increment 
>> that property each time a new instance of a class is created, starting from 
>> a particular number. How would I approach this in EDG? Let's say the class 
>> instance is Animal with property *autoIncrementID*. Each time I create a 
>> new Animal I would like the *autoIncrementID *to be incremented by 1.
>>
>> Br,
>> Maja
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "TopBraid Suite Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected].
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/topbraid-users/01759423-765a-4084-a991-2caa46eb49e8n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/topbraid-users/01759423-765a-4084-a991-2caa46eb49e8n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>>
>> UK +44 (0) 7788 561308 <+44%207788%20561308>
>> US +1 (336) 283-0808 <(336)%20283-0808>‬
>>
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "TopBraid Suite Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected].
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/topbraid-users/6CE83445-5B78-424E-A92F-7E5FDE25E275%40topquadrant.com
>>  
>> <https://groups.google.com/d/msgid/topbraid-users/6CE83445-5B78-424E-A92F-7E5FDE25E275%40topquadrant.com?utm_medium=email&utm_source=footer>
>> .
>>
>>
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "TopBraid Suite Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected].
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/topbraid-users/26067D09-E4E1-4C22-908D-814BDB0E23D7%40topquadrant.com
>>  
>> <https://groups.google.com/d/msgid/topbraid-users/26067D09-E4E1-4C22-908D-814BDB0E23D7%40topquadrant.com?utm_medium=email&utm_source=footer>
>> .
>>
>>
>> UK +44 (0) 7788 561308 <+44%207788%20561308>
>> US +1 (336) 283-0808 <(336)%20283-0808>‬
>>
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "TopBraid Suite Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected].
>>
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/topbraid-users/FB3F08CF-85E9-49B8-B3A7-5F272C0AE3C7%40topquadrant.com
>>  
>> <https://groups.google.com/d/msgid/topbraid-users/FB3F08CF-85E9-49B8-B3A7-5F272C0AE3C7%40topquadrant.com?utm_medium=email&utm_source=footer>
>> .
>>
>>
>>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "TopBraid Suite Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
>
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/topbraid-users/d968627f-a6cd-4089-b0e4-6c320b423bd6n%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/topbraid-users/d968627f-a6cd-4089-b0e4-6c320b423bd6n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/topbraid-users/c2d91ae4-299f-4d5b-a3da-2defe076cf83n%40googlegroups.com.

Reply via email to