adding Datafile with DatafileParameter

24 views
Skip to first unread message

c.felder.m.sc

unread,
May 15, 2012, 5:25:28 AM5/15/12
to icatproje...@googlegroups.com
Hello,

I've tried to add a Datafile with DatafileParameters but unfortunately I can not get it working.
I first tried to create the whole structure Datafile with DatafileParameter and submit it with one create call. This caused in an ICatInternalException.
Maybe this is related to the DatafileId because DatafileParameterPK relies on it and before the Datafile is not created I do not know the Id.
Or does the system automatically set this values?
So in a second try I created the Datafile first and then the DatafileParameter and call update on Datafile. The Datafile is created but without
the DatafileParameterCollection.

Can someone provide an short example please or is there some documentation on data acquisition in ICAT because i did not find anything?

The following code shows my second try (see attached file for complete source code, @method addDatafileParameterExample2):

        Calendar cal = Calendar.getInstance();

        cal.setTimeInMillis(System.currentTimeMillis());

        Datafile file = new Datafile();

        file.setName(System.currentTimeMillis()+".raw");

        file.setDatasetId(dataSetId);

        file.setFileSize(256L * 1024L * 1024L+1L);

        file.setChecksum("ffffffffffffffffffffffffffffffff");

        file.setCommand("md5"); // command for calculating checksum?

        file.setDatafileCreateTime(cal);

        file.setDatafileModifyTime(cal);

        file.setLocation("rsync://jcnsnfs.jcns.frm2/instrument/kws/measurement1/"+file.getName());

        

        file.setId((Long) icat.create(this.sessionId, file));

        

        DatafileParameter[] param = new DatafileParameter[1];

        DatafileParameterPK pk = new DatafileParameterPK();

        pk.setName("testString");

        pk.setUnits("characters");

        pk.setDatafileId(file.getId());

        

        param[0] =  new DatafileParameter();

        param[0].setDescription("test parameter");

        param[0].setStringValue("Hello World");

        param[0].setValueType(ParameterValueType.STRING);

        param[0].setDatafileParameterPK(pk);

        

        file.setDatafileParameterCollection(param);

        

        this.icat.update(this.sessionId, file);

        

        System.out.println(file.getName());

        System.out.println("   fileId: "+file.getId());

        System.out.println("datasetId: "+file.getDatasetId());


Thanks for any help.

Christian

JiCatClient.java

Steve Fisher

unread,
May 16, 2012, 7:27:00 PM5/16/12
to c.feld...@gmail.com, icatproje...@googlegroups.com
On 15 May 2012 10:25, c.felder.m.sc <c.feld...@gmail.com> wrote:
> Hello,
>
> I've tried to add a Datafile with DatafileParameters but unfortunately I can
> not get it working.

Yes I must improve the documentation. However this will be
documentation for 4.1 rather than 4.0. I am working hard to get 4.1
out as this is much more consistent and hopefully easier to
understand. Also all the mess with compound primary keys has been
removed.
This won't work - you need to create the DatafileParameter making sure
that it references the existing Datafile

>
>
>
>         System.out.println(file.getName());
>
>         System.out.println("   fileId: "+file.getId());
>
>         System.out.println("datasetId: "+file.getDatasetId());
>
>
> Thanks for any help.
>
> Christian
>
> --
> You received this message because you are subscribed to the Google Groups
> "icatproject-support" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/icatproject-support/-/LfcMy-wW4vUJ.
> To post to this group, send email to icatproje...@googlegroups.com.
> To unsubscribe from this group, send email to
> icatproject-sup...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/icatproject-support?hl=en.

c.felder.m.sc

unread,
May 22, 2012, 3:27:41 AM5/22/12
to icatproje...@googlegroups.com, c.feld...@gmail.com
Thanks for your reply,

but unfortunately I can not get it working. I always run into {client.icat3.uk}IcatInternalException:null
The following code shall create an DatafileParameter for an existing Datafile with id = long fileId

    public void createParameterForFile(long fileId) throws ValidationException,

            IcatInternalException, NoSuchObjectFoundException,

            InsufficientPrivilegesException, SessionException,

            ObjectAlreadyExistsException, RemoteException

    {

        DatafileParameter p = new DatafileParameter();

        DatafileParameterPK pk = new DatafileParameterPK(fileId,

                "PrimaryKeyName", "Unit");

        p.setDatafileParameterPK(pk);


        p.setStringValue("HelloWorld");

        p.setDescription("StringValue");


        p.setValueType(ParameterValueType.STRING);


        this.icat.create(this.sessionId, p);

    }


Stacktrace:

AxisFault

 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server

 faultSubcode: 

 faultString: uk.icat3.exceptions.IcatInternalException

 faultActor: 

 faultNode: 

 faultDetail: 

{client.icat3.uk}IcatInternalException:null


uk.icat3.exceptions.IcatInternalException

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)

at java.lang.reflect.Constructor.newInstance(Constructor.java:513)

at java.lang.Class.newInstance0(Class.java:355)

at java.lang.Class.newInstance(Class.java:308)

at org.apache.axis.encoding.ser.BeanDeserializer.<init>(BeanDeserializer.java:104)

at org.apache.axis.encoding.ser.BeanDeserializer.<init>(BeanDeserializer.java:90)

at uk.icat3.client.IcatInternalException.getDeserializer(IcatInternalException.java:116)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at org.apache.axis.encoding.ser.BaseDeserializerFactory.getSpecialized(BaseDeserializerFactory.java:154)

at org.apache.axis.encoding.ser.BaseDeserializerFactory.getDeserializerAs(BaseDeserializerFactory.java:84)

at org.apache.axis.encoding.DeserializationContext.getDeserializer(DeserializationContext.java:464)

at org.apache.axis.encoding.DeserializationContext.getDeserializerForType(DeserializationContext.java:547)

at org.apache.axis.message.SOAPFaultDetailsBuilder.onStartChild(SOAPFaultDetailsBuilder.java:157)

at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)

at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:501)

at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:179)

at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:377)

at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2756)

at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)

at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)

at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)

at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)

at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)

at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)

at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)

at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)

at javax.xml.parsers.SAXParser.parse(SAXParser.java:395)

at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)

at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)

at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)

at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)

at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)

at org.apache.axis.client.Call.invokeEngine(Call.java:2784)

at org.apache.axis.client.Call.invoke(Call.java:2767)

at org.apache.axis.client.Call.invoke(Call.java:2443)

at org.apache.axis.client.Call.invoke(Call.java:2366)

at org.apache.axis.client.Call.invoke(Call.java:1812)

at uk.icat3.client.ICATPortBindingStub.create(ICATPortBindingStub.java:3669)

at application.icatclient.JiCatClient.createParameterForFile(JiCatClient.java:304)

at application.icatclient.JiCatClient.run(JiCatClient.java:318)

at application.icatclient.JiCatClient.main(JiCatClient.java:330)


Steve Fisher

unread,
May 22, 2012, 1:53:11 PM5/22/12
to icatproje...@googlegroups.com, c.feld...@gmail.com
There is a footnote in the API doc that says: 2Currently, because of
the database structure, this does not work for DatasetParameters nor
for DatafileParameters.

I am working to produce release 4.1 at the moment which I hope will
not have these problems

Steve
> --
> You received this message because you are subscribed to the Google Groups
> "icatproject-support" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/icatproject-support/-/xmI71nVjm3sJ.
Reply all
Reply to author
Forward
0 new messages