@philippeVerney,
We have re-written the code as follows:
String fileName = System.currentTimeMillis() + "";
String filePath = fileName + ".epc";
EpcDocument srcEpcDoc = new EpcDocument(filePath);
DataObjectRepository repo = new DataObjectRepository();
repo.createHdfProxy("", "External HDF5 proxy", srcEpcDoc.getStorageDirectory(),
srcEpcDoc.getName() + ".h5", DataObjectRepository.openingMode.READ_WRITE);
// Create a new WellboreFeature
String title = "WellboreFeature ABC";
WellboreFeature wellboreFeature = repo.createWellboreFeature("", title);
String wellborefeatureUuid = wellboreFeature.getUuid();
srcEpcDoc.serializeFrom(repo);
srcEpcDoc.close();
repo.clear();
// Deserialize from existing .epc file
srcEpcDoc = new EpcDocument(filePath);
repo = new DataObjectRepository();
srcEpcDoc.deserializeInto(repo, DataObjectRepository.openingMode.OVERWRITE);
title = "WellboreFeature ABC - Updated";
// wellboreFeature = repo.createWellboreFeature(wellborefeatureUuid, title);
wellboreFeature = (WellboreFeature)repo.getDataObjectByUuid(wellborefeatureUuid);
wellboreFeature.setTitle(title);
// Serialize to file
srcEpcDoc.serializeFrom(repo);
srcEpcDoc.close();
repo.clear();
This is similar to what you recommended - we are good with this.
Philippe: HdfProxy would probably be in conflict at some points. Please serialize your repo in a different file and delete the previous opened file if necessary. To FESAPI, EPC documents are considered transient and should not be used as persistent databases.
Wanted to ask why is it risky to write back to the same .epc file ?
We are deserializing in OVERWRITE mode precisely for this purpose only, isn’t it ?
srcEpcDoc.deserializeInto(repo, DataObjectRepository.openingMode.OVERWRITE);
We are kind of treating the resqml file as a persistent data source in our workflows:
- Write Wellbore to a file
- Add Trajectories to the same file at a later point in time
- Add more data types to the same file if needed at a later point in time etc.
If we can’t serialize it back to the same file, the above workflows become very difficult.
My understanding is Resqml is supposed to support updating existing data and adding new data to existing file - and this is working form what we tested so far.
Please advise.
Thanks,
Shakir