Search the FirstSpirit Knowledge Base
Hello, I am writing a workflow script for datasets and have a problem with Media. This is what I work with:
locationfinder_download mapping:
locationfinder_downloaditem mapping:
There's a table of Regions, containing lists of Downloads. Downloads themselves contain some Download Items.
When I click on some Region and execute the script, first I get all outgoing references:
content2ScriptContext = (Content2ScriptContext) context;
row = content2ScriptContext.getSelectedRow();
storeElement = content2ScriptContext.getStoreElement();
schema = storeElement.getSchema();
dataSet = storeElement.getDataset(row);
currentEntity = dataSet.getEntity();
releaseSession = currentEntity.getSession();
refs = schema.getOutgoingReferences(currentEntity);
Then, I release every dependent object and check, if any of those contains "locationfinder_downloaditemList". If I find it, I add it to some ArrayList and release those objects in another loop:
ReferenceEntry[] outgoingReferences = refs;
for(ReferenceEntry entry : outgoingReferences) {
releaseSession.release(entry.getReferencedObject());
releaseSession.commit();
if(entry.getReferencedObject().getValue("locationfinder_downloaditemList") != null){
referencedDatasets.add(entry.getReferencedObject().getValue("locationfinder_downloaditemList"));
}
}
Finally, when releasing objects from referencedDatasets, I check for an object that contains field "file". That would be Download Item, which has the picture that I want to release:
for (List list : referencedDatasets){
for(Object d : list){
releaseSession.release((Entity) d);
releaseSession.commit();
if(((Entity)d).getValue("file") != null){
//do something here
}
}
}
The problem is that I get some XML data (EditorWrapper as far as I understood) and have no idea, what to do with it:
Is there any way to release this picture following my logic? Or maybe it can be done somehow different?
Feel free to ask questions if something is unclear. I would be very helpful for any piece of advice.
My entire script is attached in case snippets were not informative enough.
Found a sollution. I parse the XML, get UID and then use mediaStore.getMediaByUid() to get the image.
Found a sollution. I parse the XML, get UID and then use mediaStore.getMediaByUid() to get the image.