public EventVo getEvent(EventRefVo voRef) {
    if (voRef == null) throw new DomainRuntimeException("Cannot get EventVo for null EventRefVo");

    DomainFactory factory = getDomainFactory();
    Event doEvent = (Event) factory.getDomainObject(Event.class, voRef.getID_Event());
    return EventVoAssembler.create(doEvent);
  }
  public EventVo save(
      EventVo event,
      EventTargetVoCollection eventTargets,
      EventExternalEventMappingVoCollection externalToBeAdded,
      EventExternalEventMappingVoCollection externalToBeDeleted,
      EventRTTEventVoCollection rttToBeAdded,
      EventRTTEventVoCollection rttToBeDeteled)
      throws StaleObjectException, ForeignKeyViolationException, UniqueKeyViolationException,
          DomainInterfaceException {
    if (event == null) {
      throw new DomainRuntimeException("Invalid record");
    }
    if (!event.isValidated()) {
      throw new CodingRuntimeException("Record not validated");
    }

    // CheckForUniq
    checkForUniqRecords(event, externalToBeAdded, rttToBeAdded);

    DomainFactory factory = getDomainFactory();

    if (eventTargets != null) {
      event.setEventTargets(eventTargets.toIRecordStatusTreeArray());
    }

    RecordStatusValidator helper = new RecordStatusValidator(factory, getLookupService());
    helper.validate(event);

    // Save Event
    Event domainRecord = EventVoAssembler.extractEvent(factory, event);

    if (domainRecord.getName() != null) {
      domainRecord.setUpperName(domainRecord.getName().toUpperCase());
    }

    factory.save(domainRecord);
    event = EventVoAssembler.create(domainRecord);

    // Save External
    saveExternal(event, externalToBeAdded, externalToBeDeleted, factory, domainRecord);
    // Save RTT
    saveRTT(event, rttToBeAdded, rttToBeDeteled, factory, domainRecord);
    // Save Targets
    saveTargets(event, eventTargets, factory);

    return EventVoAssembler.create(domainRecord);
  }
  @SuppressWarnings("unchecked")
  private EventVoCollection checkForUniqEvent(EventVo record) {
    DomainFactory factory = getDomainFactory();
    StringBuffer hql = new StringBuffer();
    ArrayList<String> names = new ArrayList<String>();
    ArrayList<Serializable> values = new ArrayList<Serializable>();

    hql.append(
        "select event from Event as event left join event.status as status where event.name = :name and status.id = :id_status ");
    names.add("name");
    names.add("id_status");
    values.add(record.getName());
    values.add(PreActiveActiveInactiveStatus.ACTIVE.getID());

    if (record.getID_EventIsNotNull()) {
      hql.append(" and event.id <> :id  ");
      names.add("id");
      values.add(record.getID_Event());
    }

    List collection = factory.find(hql.toString(), names, values);
    return EventVoAssembler.createEventVoCollectionFromEvent(collection);
  }