- public Object execute(ExecutionEvent event) throws ExecutionException {
- NewDerivedUnitBaseWizard wizard = new NewDerivedUnitBaseWizard();
- wizard.init(null, null);
- WizardDialog dialog = new WizardDialog(HandlerUtil.getActiveShell(event), wizard);
- dialog.open();
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ ConversationHolder conversation = CdmStore.createConversation();
+ conversation.bind();
+ FieldUnit fieldUnit = FieldUnit.NewInstance();
+ DerivedUnit derivedUnit = DerivedUnit.NewInstance(SpecimenOrObservationType.PreservedSpecimen);
+ DerivationEvent.NewSimpleInstance(fieldUnit, derivedUnit, DerivationEventType.GATHERING_IN_SITU());
+ fieldUnit.setCacheStrategy(new DerivedUnitFacadeFieldUnitCacheStrategy());
+ derivedUnit.setCacheStrategy(new DerivedUnitFacadeCacheStrategy());
+ CdmStore.getService(IOccurrenceService.class).save(fieldUnit);
+ CdmStore.getService(IOccurrenceService.class).save(derivedUnit);
+ conversation.commit();
+ DerivateViewEditorInput input = new DerivateViewEditorInput(Collections.singleton(fieldUnit.getUuid()));
+ try {
+ EditorUtil.open(input);
+ } catch (PartInitException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+// NewDerivedUnitBaseWizard wizard = new NewDerivedUnitBaseWizard();
+// wizard.init(null, null);
+// WizardDialog dialog = new WizardDialog(HandlerUtil.getActiveShell(event), wizard);
+// dialog.open();