Peter,

A bit of persistence code follows.  It is a command to be run from from the 
OSGi prompt. It loads three EMF compliant documents and persists them into 
MongoDB.  There's nothing production grade here, just exercising some 
functionality.

public void cda() {

log.info("cda");

// Load a clinical document from the filesystem.

File path = new File(

"/Users/gcr/Documents/ehrWorkspace/ehrWorkArea/samples");

File cda = new File(path, "SampleCDADocument.xml");

File cdawdt = new File(path, "SampleCDADocumentToTestDatatypes.xml");

File cdawocl = new File(path, "SampleCDADocumentToTestOCL.xml");

File[] cdas = { cda, cdawdt, cdawocl };

URI uri = URI.createURI("mongodb://localhost/ehr/cda/");

ResourceSet resourceSet = resourceSetFactory.createResourceSet();

try {

int i = 0;

for (File file : cdas) {

Reader reader = new BufferedReader(new FileReader(file));

InputSource is = new InputSource(reader);

ClinicalDocument cd = CDAUtil.load(is);

Resource resource = resourceSet.createResource(uri);

EList<EObject> eo = resource.getContents();

eo.add(cd);

log.debug("cd.eResource()=" + cd.eResource().toString());

try {

cd.eResource().save(Collections.EMPTY_MAP);

} catch (IOException e) {

log.error("", e);

}

i++;

log.info("cd=" + cd.toString());

}

DB db = provider.getDB();

DBCollection coll = db.getCollection("cda");

log.info("cds inserted=" + i);

log.info("total cda=" + coll.count());


 } catch (Exception e) {

log.error("", e);

}

}


On Monday, 25 November 2013 07:41:15 UTC-5, Peter Kriens wrote:
>
> I am doing some research on OSGi and persistence and I find the whole Java 
> persistence story quite confusing and complex. Part of my problem is that I 
> see lots of frameworks but it is quite hard to see code that really uses 
> those frameworks. Virtually all tutorials and examples look highly 
> contrived and seem to totally ignore issues like caching, security and seem 
> to be rather lax concerning transactions.   
>
> I wonder if people in this forum could share with me a typical production 
> source file showing: 
>
>         How entities are defined 
>         The persistent use of the entity, i.e. the part where the SQL will 
> be generated. I.e. places where the PersistenceManager, EntityManager, SQL 
> generation is used 
>         How results are cached 
>
> A single source or class file per issue is best. Adding a small 
> description how you use persistence (Aries, JPA, JDO, JDBC, etc), the 
> primary issues you face, and describe your environment is highly 
> appreciated. 
>
> I know from my own experience that there is often a feeling that your own 
> code is not up for showing to others but please send me the raw 
> unadulterated code; I need to see how it is today, not how you think it 
> should be. Obviously I am not interested in what the code does or where it 
> is used so feel free to remove comments (if any!) and change names. I am 
> just looking for a couple of hundred of real world samples to extract the 
> patterns that are actually popular in our industry. 
>
> Obviously I will not share that code with anyone and treat it fully 
> confidential. Also would appreciate a little description how you use 
> persistence in OSGi. 
>
> So in this case, do not ask what the OSGi can do for you, but for once, 
> ask what you can do for the OSGi! ;-) 
>
> Please? Come on, it only takes 3 minutes. Send your 4 files to: 
> [email protected] 
>
> Kind regards, 
>
>         Peter Kriens 
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to