@Override
public void runWithEvent(Event event) {
logger.info("Executing 'create object property' action: " + event);
ObjectProperty op = objectPropertyFactory.createObjectProperty(objectTemplate.getCampaign(), false);
logger.trace("ot: " + op);
// give the property a name that isn't being used
String proposedName = "";
boolean inUse = false;
do {
proposedName = "property-" + sequence;
logger.trace("proposedName: " + proposedName);
inUse = false;
for(ObjectProperty prop : objectTemplate.getProperties()) {
logger.trace("prop: " + prop);
if(proposedName.equals(prop.getName())) {
logger.debug("name is in use: " + proposedName);
inUse = true;
break;
}
}
logger.debug("increment sequence");
sequence++;
} while(inUse);
op.setName(proposedName);
// try {
// // create a dialog to get information from the user
// IObjectTemplateBuilderDialog dialog = (IObjectTemplateBuilderDialog)appContext.getBean(
// "objectTemplateBuilderDialog", new Object[] {
// PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), ot });
//
// objectTemplateBuilder.setDialog(dialog);
//
// if(!objectTemplateBuilder.buildObjectTemplate(ot)) {
// logger.info("Object template build was incomplete; see previous log entries for details.");
//
// // TODO: alert service
//
// return;
// }
// }
// catch(ObjectBuilderException e) {
// logger.error("Exception while trying to build object property: " + e.getLocalizedMessage(), e);
//
// // TODO: alert service
//
// return;
// }
objectTemplate.addProperty(op);
op.setObjectTemplate(objectTemplate);
// save the object property and the object template
try {
objectTemplate.save();
}