<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to JavaClient</title><link>https://sourceforge.net/p/commondatamodel/wiki/JavaClient/</link><description>Recent changes to JavaClient</description><atom:link href="https://sourceforge.net/p/commondatamodel/wiki/JavaClient/feed" rel="self"/><language>en</language><lastBuildDate>Wed, 02 Sep 2015 08:16:31 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/commondatamodel/wiki/JavaClient/feed" rel="self" type="application/rss+xml"/><item><title>JavaClient modified by Anonymous</title><link>https://sourceforge.net/p/commondatamodel/wiki/JavaClient/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;strong&gt;Content&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Requirements&lt;/li&gt;
&lt;li&gt;Setting up The CDMA library&lt;/li&gt;
&lt;li&gt;Getting access to a dataset&lt;/li&gt;
&lt;li&gt;Choosing the access mode&lt;/li&gt;
&lt;li&gt;Reading data&lt;/li&gt;
&lt;/ul&gt;
&lt;hr/&gt;
&lt;h1 id="requirements"&gt;Requirements&lt;/h1&gt;
&lt;h2 id="mandatory"&gt;Mandatory&lt;/h2&gt;
&lt;p&gt;To make the CDMA working the following is required: &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;to have the CDMA core package in class path &lt;/li&gt;
&lt;li&gt;to have the OSGI bundle in class path (available from eclipse update site) &lt;/li&gt;
&lt;li&gt;to have the JDom bundle in class path (available from eclipse update site) &lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="optional-extended-dictionary-mechanism"&gt;Optional Extended Dictionary mechanism&lt;/h2&gt;
&lt;p&gt;To use the Extended Dictionary mechanism, two things are required: &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;a system property &lt;em&gt;CDM_DICTIONARY_PATH&lt;/em&gt; declaring where to find view dictionaries &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img alt="" rel="nofollow" src="http://cdma.googlecode.com/svn/wiki/images/java_sys_prop.png"/&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;having installed mapping dictionaries into sub-folder having the same name as the plug-in they belong to &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img alt="" rel="nofollow" src="http://cdma.googlecode.com/svn/wiki/images/java_deploy_folder.png"/&gt;&lt;/p&gt;
&lt;hr/&gt;
&lt;h1 id="setting-up-the-cdma-library"&gt;Setting up The CDMA library&lt;/h1&gt;
&lt;p&gt;CDMA classes are accessible through the core packages. The main class a Java client uses is &lt;code&gt;org.gumtree.data.Factory&lt;/code&gt;. This is the entry point for using the CDMA, it is a singleton static object. It will be used to instantiate a plug-in. &lt;/p&gt;
&lt;h1 id="getting-access-to-a-dataset"&gt;Getting access to a dataset&lt;/h1&gt;
&lt;p&gt;A CDMA dataset is a handle for all the data of an experiment. Getting access to a dataset is done through the CDMA factory. Those two samples show how to proceed: &lt;/p&gt;
&lt;p&gt;- auto-detect a plug-in and instantiate both plug-in's factory and dataset &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;// Auto detecting a plug-in for an URI
URI uri = new URI( "/uri/to/reach/my/datasource" );
IFactory factory = Factory.getFactory( uri );

// Instantiate the dataset according that auto detected plug-in
IDataset dataset = factory.createDatasetInstance( uri );
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;- auto-detect a plug-in and instantiate the correct dataset &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;// Auto detect a plug-in for an URI and
// get the associated dataset
URI uri = new URI( "/uri/to/reach/my/datasource" );
IDataset dataset = Factory.openDataset( uri );
&lt;/pre&gt;&lt;/div&gt;


&lt;hr/&gt;
&lt;h1 id="choosing-the-access-mode"&gt;Choosing the access mode&lt;/h1&gt;
&lt;p&gt;The CDMA library offers two way of accessing data. &lt;/p&gt;
&lt;h2 id="standard-parsing-physical-way"&gt;Standard parsing (physical) way&lt;/h2&gt;
&lt;p&gt;The so called &lt;em&gt;standard&lt;/em&gt; way needs a perfect knowledge of the data organization, like for all others data access API. You would choose this way for a strictly local program and only if you are absolutely sure there is no need to share it or if you need to make a GUI data browser. &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;// Returns the physical root group
// Thus, all subsequents calls to sub-groups and dataitems will be based on 
// the physical data organization.
IGroup root = dataset.getRootGroup();
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;We can now browse the dataset to get data items &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;// Get a specific sub-group
IGroup a_group = root.getGroup("sub_group");

// Get all sub-groups
List&amp;lt;IGroup&amp;gt; list_groups = root.getGroupList();

// Get a specific sub data item
IDataItem a_item = a_group.getDataItem("dataitem_name");

// Get all sub data item
List&amp;lt;IDataItem&amp;gt; list_groups = root.getgetDataItemList();
&lt;/pre&gt;&lt;/div&gt;


&lt;h2 id="using-the-standard-dictionary-mechanism"&gt;Using the standard dictionary mechanism&lt;/h2&gt;
&lt;h2 id="using-the-extended-dictionary-mechanism"&gt;Using the extended dictionary mechanism&lt;/h2&gt;
&lt;p&gt;The other way of accessing data uses the dictionary mechanism. It allows writing applications with no need to know something about the data organization. Thus applications using this mechanism can access data regardless the way they are stored without need to change their source code. &lt;/p&gt;
&lt;p&gt;In order to be able to use the dictionary mechanism, a data definition document have to be selected. This kind of XML document is called a &lt;em&gt;view&lt;/em&gt;. All view documents must be suffixed by '&lt;code&gt;_view&lt;/code&gt;' ('my_app_view.xml', 'my_other_app_view.xml'). To select the view insert the following code: &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;// View (data definition document) selection
Factory.setActiveView("my_app");
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;We now can get an handle to the logical root group, and get access to the data items &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;// Returns the logical root group
// Thus, all subsequents calls to sub-groups and dataitems will be based on 
// a logical data organization driven by a data definition document.
ILogicalGroup root = dataset.getLogicalRoot();

IDataItem a_item = root.getDataItem("a_key_name");
&lt;/pre&gt;&lt;/div&gt;


&lt;hr/&gt;
&lt;h1 id="reading-data"&gt;Reading data&lt;/h1&gt;
&lt;p&gt;Once you get a data item through a reference to a IDataItem object, you may want to read its value. Data is accessible through IArray objects. An array can handle all type of data, starting from scalar (single value) to multi-dimensional values. &lt;/p&gt;
&lt;p&gt;Using the generic method is applicable to all data kind: &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;IArray array = a_item.getData();
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;If the data is assumed to be a single value (scalar type), you can use a dedicated set of convenience methods like: &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;double double_value = double_type_item.readScalarDouble();
int integer_value = integer_type_item.readScalarInt();
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;If the actual value does not match the requested type, it is converted. &lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Anonymous</dc:creator><pubDate>Wed, 02 Sep 2015 08:16:31 -0000</pubDate><guid>https://sourceforge.net1472a382b82264972e90542d351e9be84c1b48fb</guid></item></channel></rss>