private void saveExternal(
      EventVo event,
      EventExternalEventMappingVoCollection externalToBeAdded,
      EventExternalEventMappingVoCollection externalToBeDeleted,
      DomainFactory factory,
      Event domainRecord)
      throws StaleObjectException, ForeignKeyViolationException {
    // Save External
    if (externalToBeAdded != null) {
      for (int i = 0; i < externalToBeAdded.size(); i++) {
        EventExternalEventMapping domainExternal =
            EventExternalEventMappingVoAssembler.extractEventExternalEventMapping(
                factory, externalToBeAdded.get(i));
        domainExternal.setEvent(domainRecord);
        if (domainExternal.getStatus().equals(getDomLookup(PreActiveActiveInactiveStatus.ACTIVE))
            && domainExternal.getActivatedDateTime() == null) {
          domainExternal.setStatus(getDomLookup(PreActiveActiveInactiveStatus.ACTIVE));
          domainExternal.setActivatedBy(getUser());
          domainExternal.setActivatedDateTime(new Date());
        } else if (domainExternal
            .getStatus()
            .equals(getDomLookup(PreActiveActiveInactiveStatus.INACTIVE))) {
          if (domainExternal.getInactivatedBy() == null) {
            domainExternal.setInactivatedBy(getUser());
            domainExternal.setInactivatedDateTime(new Date());
          }
        }

        factory.save(domainExternal);
      }
    }

    if (externalToBeDeleted != null) {
      for (int i = 0; i < externalToBeDeleted.size(); i++) {
        EventExternalEventMapping domainExternal =
            EventExternalEventMappingVoAssembler.extractEventExternalEventMapping(
                factory, externalToBeDeleted.get(i));
        factory.delete(domainExternal);
      }
    }
  }
  @SuppressWarnings("unchecked")
  public EventExternalEventMappingVoCollection getEventExternalEventMapping(
      EventRefVo voRef, PreActiveActiveInactiveStatus status) {
    DomainFactory factory = getDomainFactory();
    ArrayList markers = new ArrayList();
    ArrayList values = new ArrayList();

    String query =
        "select eeem from EventExternalEventMapping as eeem where eeem.event.id = :idEvent";
    markers.add("idEvent");
    values.add(voRef.getID_Event());

    if (status != null) {
      query += " and eeem.event.status = :status";
      markers.add("status");
      values.add(getDomLookup(status));
    }

    List eeem = factory.find(query, markers, values, 1000);
    return EventExternalEventMappingVoAssembler
        .createEventExternalEventMappingVoCollectionFromEventExternalEventMapping(eeem);
  }