change the name of the document at run time

Hi ,

I have a document processExchange.
Also i have a input called documentName
I want to publish the document processExchange but the but the name of the document hsould change to input which is provided to documentName.

How i can implement this

wat i am guessing is you are trying to publish “processExchange” but on subscription end you are expecting document with name “documentName”, it’s kind of wiered to be honest … if you still need it, include one extra document with “processExchange” in input and then map the document to target document “documentName” in subscription service at step-1 and then continue with the processing you want to do…

No this is not what i want
documentName is a string not a document.

so while publishing processExchange.
I want it to be published as documentName
like if the documentName is OrderName

processExchange should be published as ordername
(That means it should be the reference of the document processExchange but name should be ordername)

Hello,

So you want to say, that you want orderName shown in output as document name, regardless of its initial name when in input…??

Regards.

yes that is what i want

Hello,

I am not very good in Java, but yes, can suggest you to use this, this should be helpful to make custom service. Sorry could not help much, but yes, I found this most suitable.

public class Rename {
public static void main(String[] argv) throws IOException {
File f = new FileCOLOR=#000000[/color];
f.renameTo(new FileCOLOR=#000000)[/color];
}
}

Comments welcomed.

Regards,
Suvigya

This will rename a fie but i want to rename a document how i can do it

What is reason/need to change document name at runtime?

Create

Hi Shahid,

Need is like we have to publish aroung 10 documents which have the same structure
so we are creating a generic service to publish them otherwise we have to create 10 publishable document of same structure and also 10 service which will do the same thing.

Thanks
Renuka

You’re going to need 10 document types (publishable). Otherwise you won’t be able to publish them.

One approach is to define the common structure in a (non-publishable) doc type. Then define the 10 publishable doc types that reference that structure and use the the desired names.

What’s driving the desire to use the same structure with 10 different names? Perhaps another workable approach is to use one publishable doc type with a field that identifies which sort of thing it is. Then if desired/necessary, use subscription filters.

pub/sub doesn’t depend on name of document, instead the documentTypeName you pass in publish (the actual IS document type it refers to), if the documents are having same structure, I assume they refer to same IS publishable document type.
In that case just loop over to publish them, if you want to differentiate you should differentiate using some eventtype or filter values in the document.

Anyways your requirement can be achieved by converting the document to XML and replace the root tag with whatever name you want, then again convert the XML back to document now you will get the document with name you wanted. In this case I assume that you would like to publish as a different documentTypeName, so remember to pass the correct one.

  • regards
    DC

" pub/sub doesn’t depend on name of document"

That depends on IS settings. The default settings enforce that the document being published match the document type. In this case, the structure of the document, including names, must match the Broker document type definition.

I think you can write a java service, where while creating output document you can use the documentName.

While creating pipelineCursor for output, there we provide document or pipeline variable name. that you can keep as run time.

Sorry i am not very good at java, hence not able to provide you with sample.

// pipeline
IDataCursor pipelineCursor = pipeline.getCursor();
// documentName
IData documentName = IDataFactory.create();
IDataCursor documentNameCursor = documentName.getCursor();
IDataUtil.put( documentNameCursor, “abc”, “abc” );
documentNameCursor.destroy();
IDataUtil.put( pipelineCursor, “documentName”, documentName );
pipelineCursor.destroy();

in the above code documentName marked in bold, if you generate it dynamically. that should fulfill your requirement