Examples of IdGenerator


Examples of org.lilyproject.repository.api.IdGenerator

import static org.mockito.Mockito.when;

public class FieldValueStringConverterTest {
    @Test
    public void testFromString() throws Exception {
        IdGenerator idGenerator = new IdGeneratorImpl();

        ValueType valueType = mock(ValueType.class);

        when(valueType.getBaseName()).thenReturn("STRING");
        assertEquals("foo", FieldValueStringConverter.fromString("foo", valueType, idGenerator));

        when(valueType.getBaseName()).thenReturn("INTEGER");
        assertEquals(new Integer(123), FieldValueStringConverter.fromString("123", valueType, idGenerator));

        when(valueType.getBaseName()).thenReturn("LONG");
        assertEquals(new Long(12345), FieldValueStringConverter.fromString("12345", valueType, idGenerator));

        when(valueType.getBaseName()).thenReturn("DOUBLE");
        assertEquals(new Double(12345.6), FieldValueStringConverter.fromString("12345.6", valueType, idGenerator));

        when(valueType.getBaseName()).thenReturn("DECIMAL");
        assertEquals(new BigDecimal("12345.12345"), FieldValueStringConverter.fromString("12345.12345", valueType, idGenerator));

        when(valueType.getBaseName()).thenReturn("URI");
        assertEquals(new URI("http://www.ngdata.com/"),
                FieldValueStringConverter.fromString("http://www.ngdata.com/", valueType, idGenerator));

        when(valueType.getBaseName()).thenReturn("BOOLEAN");
        assertEquals(Boolean.TRUE, FieldValueStringConverter.fromString("true", valueType, idGenerator));
        assertEquals(Boolean.FALSE, FieldValueStringConverter.fromString("false", valueType, idGenerator));

        when(valueType.getBaseName()).thenReturn("LINK");
        assertEquals(new Link(idGenerator.newRecordId("foobar")),
                FieldValueStringConverter.fromString("USER.foobar", valueType, idGenerator));

        when(valueType.getBaseName()).thenReturn("DATE");
        assertEquals(new LocalDate(2012, 6, 28), FieldValueStringConverter.fromString("2012-06-28", valueType, idGenerator));
View Full Code Here

Examples of org.makersoft.shards.id.IdGenerator

      return null;
    } else if (shard.getShardIds().size() == 1) {
      return shard.getShardIds().iterator().next();
    } else {
      //TODO(fengkuok) 似乎从来不会走到这个逻辑
      IdGenerator idGenerator = shardedSqlSessionFactory.getIdGenerator();
      if (idGenerator != null) {
        return idGenerator.extractShardId(this.extractId(parameter));
      } else {
        // TODO(tomislav): also use shard resolution strategy if it returns only 1 shard;
        // throw this error in config instead of here
        throw new RuntimeException(
            "Can not use virtual sharding with non-shard resolving id gen");
View Full Code Here

Examples of org.neo4j.kernel.impl.nioneo.store.IdGenerator

        }

        public Void execute( GraphDatabaseService db )
        {
            Config config = getConfig( db );
            IdGenerator generator = config.getIdGeneratorFactory().get( IdType.NODE );
            for ( int i = 0; i < count; i++ )
            {
                generator.nextId();
            }
            return null;
        }
View Full Code Here

Examples of org.neo4j.kernel.impl.persistence.IdGenerator

        this.relTypeCreator = relTypeCreator;
        this.txIdGenerator = txIdGenerator;
        this.txModule = txModule;
        this.lockManager = lockManager;
        this.lockReleaser = lockReleaser;
        this.idGeneratorModule = new IdGeneratorModule( new IdGenerator() );
        this.readOnly = Boolean.parseBoolean( (String) params.get( READ_ONLY ) );
        this.backupSlave = Boolean.parseBoolean( (String) params.get( BACKUP_SLAVE ) );
        this.syncHookFactory = txSyncHookFactory;
        this.persistenceModule = new PersistenceModule();
        this.cacheManager = new AdaptiveCacheManager();
View Full Code Here

Examples of org.rssowl.core.model.dao.IDGenerator

    return template.isRoot();
  }

  private void setId(IEntity entity) {
    if (entity.getId() == null) {
      IDGenerator idGenerator = NewsModel.getDefault().getPersistenceLayer().getIDGenerator();
      long id;
     
      if (idGenerator instanceof DB4OIDGenerator)
        id = ((DB4OIDGenerator) idGenerator).getNext(false);
      else
        id = idGenerator.getNext();
     
      entity.setId(id);
    }
  }
View Full Code Here

Examples of org.rssowl.core.persist.service.IDGenerator

      /* Return early on cancellation */
      if (monitor.isCanceled() || Owl.isShuttingDown())
        return;

      /* Set ID to News and handle Description entity */
      IDGenerator generator = Owl.getPersistenceService().getIDGenerator();
      for (INews news : newNewsAdded) {

        /* Return early on cancellation */
        if (monitor.isCanceled() || Owl.isShuttingDown())
          return;

        long id;
        if (generator instanceof DB4OIDGenerator)
          id = ((DB4OIDGenerator) generator).getNext(false);
        else
          id = generator.getNext();

        news.setId(id);

        String description = ((News) news).getTransientDescription();
        if (description != null) {
View Full Code Here

Examples of org.rssowl.core.persist.service.IDGenerator

  private void setId(IEntity entity) {
    if (entity.getId() == null) {
      long id;

      IDGenerator idGenerator = getIDGenerator();
      if (idGenerator instanceof DB4OIDGenerator)
        id = ((DB4OIDGenerator) idGenerator).getNext(false);
      else
        id = idGenerator.getNext();

      entity.setId(id);
    }
  }
View Full Code Here

Examples of org.rssowl.core.persist.service.IDGenerator

  private void setId(IEntity entity) {
    if (entity.getId() == null) {
      long id;

      IDGenerator idGenerator = getIDGenerator();
      if (idGenerator instanceof DB4OIDGenerator)
        id = ((DB4OIDGenerator) idGenerator).getNext(false);
      else
        id = idGenerator.getNext();

      /*
       * We must release the read lock before we can change the id of the
       * news. This should be fine because if the News has no id, it means
       * that it's not known to anyone but the caller and we will acquire the
View Full Code Here

Examples of org.springframework.util.IdGenerator

  }

  @Test
  public void testBuildMessageWithoutIdAndTimestamp() {
    MessageHeaderAccessor headerAccessor = new MessageHeaderAccessor();
    headerAccessor.setIdGenerator(new IdGenerator() {
      @Override
      public UUID generateId() {
        return MessageHeaders.ID_VALUE_NONE;
      }
    });
View Full Code Here

Examples of org.teiid.core.id.IDGenerator

     * @throws QueryMetadataException
     * @throws TeiidComponentException
     */
    public static XMLPlan preparePlan(Command command, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, CommandContext context)
        throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
        IDGenerator idGenerator = new IDGenerator();
        idGenerator.setDefaultFactory(new IntegerIDFactory());
        AnalysisRecord analysis = new AnalysisRecord(false, DEBUG);
        try {
            if (DEBUG) {
                System.out.println("\n####################################\n" + command); //$NON-NLS-1$
            }
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.