Examples of EventSource


Examples of org.hibernate.event.spi.EventSource

  protected void entityIsTransient(MergeEvent event, Map copyCache) {

    LOG.trace( "Merging transient instance" );

    final Object entity = event.getEntity();
    final EventSource source = event.getSession();

    final String entityName = event.getEntityName();
    final EntityPersister persister = source.getEntityPersister( entityName, entity );

    final Serializable id = persister.hasIdentifierProperty() ?
        persister.getIdentifier( entity, source ) :
        null;
    if ( copyCache.containsKey( entity ) ) {
      persister.setIdentifier( copyCache.get( entity ), id, source );
    }
    else {
      ( (EventCache) copyCache ).put( entity, source.instantiate( persister, id ), true ); //before cascade!
    }
    final Object copy = copyCache.get( entity );

    // cascade first, so that all unsaved objects get their
    // copy created before we actually copy
View Full Code Here

Examples of org.hibernate.event.spi.EventSource

  protected void entityIsDetached(MergeEvent event, Map copyCache) {

    LOG.trace( "Merging detached instance" );

    final Object entity = event.getEntity();
    final EventSource source = event.getSession();

    final EntityPersister persister = source.getEntityPersister( event.getEntityName(), entity );
    final String entityName = persister.getEntityName();

    Serializable id = event.getRequestedId();
    if ( id == null ) {
      id = persister.getIdentifier( entity, source );
    }
    else {
      // check that entity id = requestedId
      Serializable entityId = persister.getIdentifier( entity, source );
      if ( !persister.getIdentifierType().isEqual( id, entityId, source.getFactory() ) ) {
        throw new HibernateException( "merge requested with id not matching id of passed entity" );
      }
    }

    String previousFetchProfile = source.getFetchProfile();
    source.setFetchProfile( "merge" );
    //we must clone embedded composite identifiers, or
    //we will get back the same instance that we pass in
    final Serializable clonedIdentifier = (Serializable) persister.getIdentifierType()
        .deepCopy( id, source.getFactory() );
    final Object result = source.get( entityName, clonedIdentifier );
    source.setFetchProfile( previousFetchProfile );

    if ( result == null ) {
      //TODO: we should throw an exception if we really *know* for sure
      //      that this is a detached instance, rather than just assuming
      //throw new StaleObjectStateException(entityName, id);

      // we got here because we assumed that an instance
      // with an assigned id was detached, when it was
      // really persistent
      entityIsTransient( event, copyCache );
    }
    else {
      ( (EventCache) copyCache ).put( entity, result, true ); //before cascade!

      final Object target = source.getPersistenceContext().unproxy( result );
      if ( target == entity ) {
        throw new AssertionFailure( "entity was not detached" );
      }
      else if ( !source.getEntityName( target ).equals( entityName ) ) {
        throw new WrongClassException(
            "class of the given object did not match class of persistent copy",
            event.getRequestedId(),
            entityName
        );
      }
      else if ( isVersionChanged( entity, source, persister, target ) ) {
        if ( source.getFactory().getStatistics().isStatisticsEnabled() ) {
          source.getFactory().getStatisticsImplementor()
              .optimisticFailure( entityName );
        }
        throw new StaleObjectStateException( entityName, id );
      }

View Full Code Here

Examples of org.hibernate.event.spi.EventSource

    upgradeLock( entity, entry, event.getLockOptions(), event.getSession() );
  }
 
  private void cascadeOnLock(LockEvent event, EntityPersister persister, Object entity) {
    EventSource source = event.getSession();
    source.getPersistenceContext().incrementCascadeLevel();
    try {
      new Cascade( CascadingActions.LOCK, CascadePoint.AFTER_LOCK, source).cascade(
          persister,
          entity,
          event.getLockOptions()
      );
    }
    finally {
      source.getPersistenceContext().decrementCascadeLevel();
    }
  }
View Full Code Here

Examples of org.hibernate.event.spi.EventSource

  public Object processCollection(Object collection, CollectionType type) throws HibernateException {
    if ( collection == CollectionType.UNFETCHED_COLLECTION ) {
      return null;
    }

    final EventSource session = getSession();
    final CollectionPersister persister = session.getFactory().getCollectionPersister( type.getRole() );

    if ( isUpdate ) {
      removeCollection( persister, extractCollectionKeyFromOwner( persister ), session );
    }
    if ( collection != null && collection instanceof PersistentCollection ) {
      final PersistentCollection wrapper = (PersistentCollection) collection;
      wrapper.setCurrentSession( session );
      if ( wrapper.wasInitialized() ) {
        session.getPersistenceContext().addNewCollection( persister, wrapper );
      }
      else {
        reattachCollection( wrapper, type );
      }
    }
View Full Code Here

Examples of org.hibernate.event.spi.EventSource

  }

  @SuppressWarnings({"unchecked"})
  protected void entityIsPersistent(PersistEvent event, Map createCache) {
    LOG.trace( "Ignoring persistent instance" );
    final EventSource source = event.getSession();

    //TODO: check that entry.getIdentifier().equals(requestedId)

    final Object entity = source.getPersistenceContext().unproxy( event.getObject() );
    final EntityPersister persister = source.getEntityPersister( event.getEntityName(), entity );

    if ( createCache.put( entity, entity ) == null ) {
      justCascade( createCache, source, entity, persister );

    }
View Full Code Here

Examples of org.hibernate.event.spi.EventSource

   */
  @SuppressWarnings({"unchecked"})
  protected void entityIsTransient(PersistEvent event, Map createCache) {
    LOG.trace( "Saving transient instance" );

    final EventSource source = event.getSession();
    final Object entity = source.getPersistenceContext().unproxy( event.getObject() );

    if ( createCache.put( entity, entity ) == null ) {
      saveWithGeneratedId( entity, event.getEntityName(), createCache, source, false );
    }
  }
View Full Code Here

Examples of org.meb.spdwldr.EventSource

    Elements eventDivs = doc.select("div.event-page-card");
    ListIterator<Element> eventsDivsIter = eventDivs.listIterator();
    List<EventSource> eventSources = new ArrayList<EventSource>();

    while (eventsDivsIter.hasNext()) {
      EventSource eventSource = null;

      Element eventDiv = eventsDivsIter.next();
      if (eventDiv.select("div.teams").size() != 0) {
        // league event
        String homeTeam = extractTeam(eventDiv, "div.teams div.home a");
        String awayTeam = extractTeam(eventDiv, "div.teams div.away a");
        String eventUri = extractTeamEventUri(eventDiv);
        if (homeTeam != null && awayTeam != null && eventUri != null) {
          eventSource = new EventSource();
          eventSource.setEventName(homeTeam + " - " + awayTeam);
          eventSource.setEventUri("www.sportowefakty.pl" + eventUri);
        }
      } else if (eventDiv.select("div.single").size() != 0) {
        // single event
        Element a = eventDiv.select("div.single a").get(0);
        String eventName = a.text();
        String eventUri = a.attr("href");
        if (eventName != null && eventUri != null) {
          eventSource = new EventSource();
          eventSource.setEventName(eventName);
          eventSource.setEventUri("www.sportowefakty.pl" + eventUri);
        }
      }

      if (eventSource != null) {
        String eventGroup = extractEventGroup(eventDiv);
        eventSource.setEventGroup(eventGroup);
        Date date = extractEventDate(eventDiv);
        if (date != null) {
          eventSource.setEventDate(DateUtils.truncate(date, Calendar.DAY_OF_MONTH));
          eventSource.setEventTime(date);
        }
        eventSources.add(eventSource);
      }
    }
    return eventSources.size() != 0 ? eventSources : null;
View Full Code Here

Examples of org.qi4j.library.eventsourcing.domain.source.EventSource

        TestEntity entity = uow.newEntity( TestEntity.class );
        entity.changedDescription( "New description" );
        uow.complete();

        // Print events
        EventSource source = (EventSource) module.findService( EventSource.class ).get();

        source.events( 0, Long.MAX_VALUE ).transferTo( Transforms.map( new Function<UnitOfWorkDomainEventsValue, String>()
                {
                    public String map( UnitOfWorkDomainEventsValue unitOfWorkDomainEventsValue )
                    {
                        return unitOfWorkDomainEventsValue.toString();
                    }
View Full Code Here

Examples of org.rhq.core.domain.event.EventSource

            throw new RuntimeException("No event definition found, should not happen");
        }

        EventSource[] evSrc = new EventSource[NUM_SOURCES];
        for (int i = 0; i < NUM_SOURCES; i++) {
            evSrc[i] = new EventSource("ESource" + 1, def, res);
        }
        long now = new Date().getTime() - ROUNDS * LINES_PER_REPORT;

        for (int round = 1; round < ROUNDS; round++) {

View Full Code Here

Examples of org.rhq.modules.integrationTests.restApi.d.EventSource

    }

    @Test
    public void testAddEventSourceForUnknownResource() throws Exception {

        EventSource es = new EventSource();
        es.setResourceId(15);
        es.setName("Event Log"); // Name of the event definition
        es.setLocation("-x-test-location");

        given()
            .header(acceptJson)
            .contentType(ContentType.JSON)
            .pathParam("id",15)
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.