* @param string
* @return
*/
private String safeGetObjectDataValue(String objectDataName, boolean formatted) {
ObjectData datum = objectInstance.getData().get(objectDataName);
logger.trace("datum: " + datum);
try {
ObjectProperty op = datum.getObjectProperty();
logger.trace("op: " + op);
if(datum == null) {
if(op == null) {
op = objectPropertyFactory.createObjectProperty(objectInstance.getCampaign(), true);
logger.trace("op: " + op);
op.setName(objectDataName);
op.setObjectTemplate(objectInstance.getObjectTemplate());
objectInstance.getObjectTemplate().addProperty(op);
objectInstance.getObjectTemplate().save();
}
datum = objectDataFactory.createObjectData(op, true);
logger.trace("datum: " + datum);
datum.setObjectInstance(objectInstance);
objectInstance.addData(datum);
objectInstance.save();
}
if(formatted) {
try {
return formatterHelper.format(op, datum);
}
catch(ObjectPropertyFormatterException e) {
logger.error("Exception caught while executing formatter: " + e.getLocalizedMessage(), e);
alertService.addAlert(new Alert(Alert.Type.ERROR, this.getClass().getSimpleName(), e
.getLocalizedMessage()));
}
}
return datum.getStringValue();
}
catch(Exception e) {
logger.error("Exception caught while trying to get object data value for character sheet editor: "
+ e.getLocalizedMessage(), e);