PDA

View Full Version : I'm trying to create masterdata via java ...


ng-first
11-23-2007, 06:46 AM
Hi all :-),
I'm working with OSM 15.50A and oracle 10.

I'm trying to create masterdata via java, in this way:

DMMasterdata cMasterdata = (DMMasterdata)WMSession.getWMSession().newElement("MASTERDATA");
cMasterdata.setValue(pdm.DB_DEFAULT_NAME, codice);
cMasterdata.setValue("CREATE_DATE",row.getDataCreazione());
cMasterdata.setCreateDate(row.getDataCreazione());
Calendar cal = Calendar.getInstance();
cal.setTime(row.getDataAggiornamento());
cMasterdata.setValue("LAST_UPDATE_DATE",cal.getTimeInMillis());

but, this peice of code produces several errors .... :-( !!

1 - I have an exception that told me that I can't update CREATE_DATE attribute ... ;
2 - even if I use the method 'setCreateDate()', the exception raises again;
3 - I have the same exception for LAST_UPDATE_DATE; and the calendar getTimeInMillis() doesn't return the correct date ...
I notice that in DB tables all date are number, but I don't know ho to convert in Date and how to convert a date in the correct number for OSM ...

Does anyone can help me?
thank in advanced,
Nadia

alexniccoli
11-26-2007, 11:45 PM
Hi Nadia
This attributes are System Attributes and so you can't set this attribute from user interface but also programmatically.You have two ways:
1.Set this values with sql statement ("UPDATE WM_ELEMENTS CREATE_DATE=value where IDEL=value2").This solution is horrible and you must pay attention.(create masterdata and execute update statement)
2.Create user attributes:in this way you can set values.

Alessandro Niccoli

ng-first
11-27-2007, 12:37 AM
Hi alex,
thank you for your suggest.
I wonder why, the same peice of java code for creating masterdata ( ... cMasterdata.setValue("CREATO_IL", row.getDataCreazione()); ... ), but running OSM 15,00A with italian DB schema, works WELL !!!

To set these values with an UPDATE SQL statement, tell if I'm correct, it is necessary to run a java code like this:
" ...
pdm.set_run_sql_password("medmgr");
pdm.enable_run_sql("medmgr");
pdm.sql_begin_work();
... "
and only an administrator user can run it ...

I need to import several draws from another system, so the create date need to be the creation date in this system .... then this attribute will be use in the title block ...

At this moment, I set the ''ORG_CREATED_AT" :-) !!!

thanks in advanced !!!
by Nadia