passing unique autocreated value to CND

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

passing unique autocreated value to CND

Dev Vale
Hello,

I am kinda new to repository defining and such, but I was wondering how to pass a unique autocreated value in CND.

to clarify what I mean:
for example, everytime a user would make a new document (with a custom document type) a unique value would be autocreated to that document to be able to identify it. (Like when a new value get's autocreated in a Database the primary key is always unique) how can I add such a value to newly created documents?

Basicly I want to make a unique Node Definition in my CND file:

I was thinking something like this:


[test:example] > hippo:document, hippostdpubwf:document, hippostd:publishableSummary orderable
jcr:title (string) autocreated

However in my CND file I need to predefine the title jcr:title (string) = 'title' autocreated which will give every document created the title value, which is not what we want, we want it to give it a unique value.

Hope I was able to make myself clear and if anyone has any pointers where I can look would be much appriciated.
Thanx in Advance


Dev
Reply | Threaded
Open this post in threaded view
|

Re: passing unique autocreated value to CND

Vijay Kiran-3
Hi Dev,

I'm not sure how you want to use the unique property, but all the hippo:document nodes have a mixin called referenceable. This mixin provides the property jcr:uuid for all the hippo:document nodes. [http://wiki.apache.org/jackrabbit/mix%3Areferenceable]

But if you want a field that is visible in the document template, then you can write a simple field plugin in CMS to do that.

./Vijay

On 04-Jun-2010, at 10:45 AM, Dev Vale wrote:

>
> Hello,
>
> I am kinda new to repository defining and such, but I was wondering how to
> pass a unique autocreated value in CND.
>
> to clarify what I mean:
> for example, everytime a user would make a new document (with a custom
> document type) a unique value would be autocreated to that document to be
> able to identify it. (Like when a new value get's autocreated in a Database
> the primary key is always unique) how can I add such a value to newly
> created documents?
>
> Basicly I can I make a unique Node Definition in my CND file:
>
> I was thinking something like this:
>
>
> [test:example] > hippo:document, hippostdpubwf:document,
> hippostd:publishableSummary orderable
> jcr:title (string) autocreated
>
> However in CND I need to predefine the title jcr:title (string) = 'title'
> autocreated which will give every document created the title value, which is
> not what we want, we want it to give it a unique value.
>
> Hope I was able to make myself clear and if anyone has any pointers where I
> can look would be much appriciated.
> Thanx in Advance
>
>
> Dev
> --
> View this message in context: http://hippo.2275632.n2.nabble.com/passing-unique-autocreated-value-to-CND-tp5138580p5138580.html
> Sent from the Plugin Development and Customization mailing list archive at Nabble.com.
> _______________________________________________
> Hippo-cms7-user mailing list and forums
> http://www.onehippo.org/cms7/support/forums.html

_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
Reply | Threaded
Open this post in threaded view
|

Re: passing unique autocreated value to CND

Dev Vale
Hello Vijay,

First of all great work on the easy forms plugin.

Well the unique property is actually used to identity the node. And I am aware of jcr:uuid however the numbers are too random to be able to identfy the document based on let's say an Xpath search query (that searches for the new document)..

So yeah I would like a field in the document that is unique so I can identify and track for example: a name change of that document (Node).

I guess I will have to make a plugin for that like you stated, I will see how that goes.
Thanx for your quick response.


Dev
Reply | Threaded
Open this post in threaded view
|

Re: passing unique autocreated value to CND

Niels van Kampenhout
In reply to this post by Dev Vale
Dev Vale wrote
for example, everytime a user would make a new document (with a custom document type) a unique value would be autocreated to that document to be able to identify it. (Like when a new value get's autocreated in a Database the primary key is always unique) how can I add such a value to newly created documents?
I recently implemented something similar for a project. The way to do this is to customize the folder workflow. Creating a new document, is actually part of the containing folder's workflow. I extended FolderWorkflowImpl and in particular the add method. You can then generate a unique identifier in any way you like, then call super and pass in the generated id.

Hope this helps,
Niels
Reply | Threaded
Open this post in threaded view
|

Re: passing unique autocreated value to CND

Dev Vale
Hello Niels,

thanks for the suggestion and sorry for the late response was away for a while.
Anyways the way I currently solved this problem was, copy the first created jcr:UUID into a field of my chosing (example: NodeUniqueID  property) due to the jcr:UUID not always staying the same, this way I would always have one unique value in the properties of a specific node (that I created).

Another question not really related to this post is creating an IDataProvider class that can be used for a DataView or RefreshingView.
What I would like to do is the following: I have a NodeIterator that has specific values it gained from an SQL Query I made.

example code:

public NodeIterator GetEXamples(Session session, String LUUID) throws RepositoryException {

    QueryManager seg = session.getWorkspace().getQueryManager();
     Query getSegTitles = seg.createQuery("SELECT * FROM EXample:testdocument WHERE   EXample:testdocumentID='"+LUUID+"' ANDEXample:testdocumentActive='true' AND jcr:path='/content/EXamoke/TDocuments/%'", Query.SQL);
     QueryResult SegTitles = getSegTitles.execute();
     NodeIterator example = SegTitles.getNodes();
     
     }

    return example;
}


I want to display some of those values in a table (Dataview or Refreshingview) however my lack of knowledge has brought me to a halt.

I think I need to create class that implements the IDataprovider however I dunno how to go about it.
I saw in a Document Selector plugin some kind of example on how to create the class however that didn't work for me.


Anyone that can direct me to a spot where I can read up on how to create a class that implements IDataProvider and uses NodeIterator values which can be passed on to DataView or RefreshingView ?
Or any other  suggestions are also welcome.
Thanx in advance.


Dev