Examples of EntityMeta


Examples of com.couchace.core.api.meta.EntityMeta

            throw CouchException.badRequest("Unsupported DeleteRequestType " + deleteRequest.getType());
        }
    }

    protected WriteResponse executeDeleteEntity(DeleteEntityRequest request) {
        EntityMeta entityMeta = metaRepository.getOrCreateEntityMeta(request.getEntityClass());

        // Request does not define documentId or revision so look to the EntityMeta
        if (entityMeta.hasId() == false) {
            throw CouchException.internalServerError("Cannot build DeleteEntityRequest for entity " + request.getEntityClass() + ", @CouchId is not specified.");
        }

        // Read the id and revision
        Object entity = request.getEntity();
        String id = entityMeta.readDocumentId(entity);
        String revision = entityMeta.readDocumentRevision(entity);

        // Create the DeleteEntityRequest
        DeleteDocumentRequest deleteDocumentRequest = couch.delete().document(id, revision);

        CouchHttpResponse couchHttpResponse = httpClient.delete(httpRequestFactory.newHttpDeleteRequest(deleteDocumentRequest));
View Full Code Here

Examples of com.couchace.core.api.meta.EntityMeta

            throw new UnsupportedOperationException(msg);
        }
    }

    protected WriteResponse executePutEntity(PutEntityRequest request) {
        EntityMeta entityMeta = metaRepository.getOrCreateEntityMeta(request.getEntityClass());

        if (request.getDocumentId() == null && request.getDocumentRevision() == null) {
            // Request does not define documentId or revision so look to the EntityMeta
            if (entityMeta.hasId()) {
                // Read the id and revision
                Object entity = request.getEntity();
                String id = entityMeta.readDocumentId(entity);
                String revision = entityMeta.readDocumentRevision(entity);
                String entityType = entityMeta.getEntityType();

                // Create the PutEntityRequest
                request = couch.put().entity(id, entityType, entity, revision);
            } else {
                throw CouchException.internalServerError("Cannot build PutEntityRequest for entity " + request.getEntityClass() + ", @CouchId is not specified.");
View Full Code Here

Examples of com.couchace.core.api.meta.EntityMeta

            throw new UnsupportedOperationException(msg);
        }
    }

    protected WriteResponse executePostEntity(PostEntityRequest request) {
        EntityMeta entityMeta = metaRepository.getOrCreateEntityMeta(request.getEntityClass());
        HttpPostRequest httpPostRequest = httpRequestFactory.newHttpPostRequest(request);

        CouchHttpResponse couchHttpResponse = httpClient.post(httpPostRequest);

        if (couchHttpResponse.isSuccess()) {
View Full Code Here

Examples of com.couchace.core.api.meta.EntityMeta

            throw CouchException.badRequest("Unsupported DeleteRequestType " + deleteRequest.getType());
        }
    }

    protected WriteResponse executeDeleteEntity(DeleteEntityRequest request) {
        EntityMeta entityMeta = metaRepository.getOrCreateEntityMeta(request.getEntityClass());

        // Request does not define documentId or revision so look to the EntityMeta
        if (entityMeta.hasId() == false) {
            throw CouchException.internalServerError("Cannot build DeleteEntityRequest for entity " + request.getEntityClass() + ", @CouchId is not specified.");
        }

        // Read the id and revision
        Object entity = request.getEntity();
        String id = entityMeta.readDocumentId(entity);
        String revision = entityMeta.readDocumentRevision(entity);

        // Create the DeleteEntityRequest
        DeleteDocumentRequest deleteDocumentRequest = couch.delete().document(id, revision);

        CouchHttpResponse couchHttpResponse = httpClient.delete(httpRequestFactory.newHttpDeleteRequest(deleteDocumentRequest));
View Full Code Here

Examples of info.archinnov.achilles.internal.metadata.holder.EntityMeta

        // Given
        PropertyMeta idMeta = PropertyMetaTestBuilder.completeBean(Void.class, Long.class).propertyName("id").type(ID).accessors().build();

        PropertyMeta nameMeta = PropertyMetaTestBuilder.completeBean(Void.class, String.class).propertyName("name").type(SIMPLE).accessors().build();

        EntityMeta meta = buildEntityMeta(idMeta, nameMeta);

        RegularStatement statement = select().from("test");

        initBuilder(statement, meta, meta.getPropertyMetas(), MANAGED);

        when(daoContext.execute(any(AbstractStatementWrapper.class))).thenReturn(futureResultSet);
        when(asyncUtils.transformFuture(futureResultSet, RESULTSET_TO_ROWS, executorService)).thenReturn(futureRows);
        when(asyncUtils.transformFuture(eq(futureRows), rowsToEntitiesCaptor.capture(), eq(executorService))).thenReturn(futureEntities);
        when(asyncUtils.transformFuture(eq(futureEntities), isoEntitiesCaptor.capture(), eq(executorService))).thenReturn(futureEntities);
        when(asyncUtils.buildInterruptible(futureEntities)).thenReturn(achillesFuturesEntities);

        when(mapper.mapRowToEntityWithPrimaryKey(eq(meta), eq(row), Mockito.<Map<String, PropertyMeta>>any(), eq(MANAGED))).thenReturn(entity);
        when(contextFactory.newContext(entity)).thenReturn(context);
        when(proxifier.buildProxyWithAllFieldsLoadedExceptCounters(entity, entityFacade)).thenReturn(entity);

        // When
        final AchillesFuture<List<CompleteBean>> actual = typedQuery.asyncGet(asyncListeners);

        // Then
        assertThat(actual).isSameAs(achillesFuturesEntities);
        verify(asyncUtils).maybeAddAsyncListeners(futureEntities, asyncListeners, executorService);

        final Function<List<Row>, List<CompleteBean>> rowsToEntities = rowsToEntitiesCaptor.getValue();
        final List<CompleteBean> entities = rowsToEntities.apply(asList(row));
        assertThat(entities).containsExactly(entity);

        final List<Function<List<CompleteBean>, List<CompleteBean>>> entitiesFunctions = isoEntitiesCaptor.getAllValues();

        final List<CompleteBean> entitiesWithTriggers = entitiesFunctions.get(0).apply(asList(entity));
        assertThat(entitiesWithTriggers).containsExactly(entity);
        verify(meta.forInterception()).intercept(entity, Event.POST_LOAD);

        final List<CompleteBean> entitiesWithProxy = entitiesFunctions.get(1).apply(asList(entity));
        assertThat(entitiesWithProxy).containsExactly(entity);
    }
View Full Code Here

Examples of info.archinnov.achilles.internal.metadata.holder.EntityMeta

                .type(PropertyType.ID).accessors().build();

        PropertyMeta nameMeta = PropertyMetaTestBuilder.completeBean(Void.class, String.class).propertyName("name")
                .type(PropertyType.SIMPLE).accessors().build();

        EntityMeta meta = buildEntityMeta(idMeta, nameMeta);

        RegularStatement statement = select("id").from("test");
        initBuilder(statement, meta, meta.getPropertyMetas(), MANAGED);

        when(daoContext.execute(any(AbstractStatementWrapper.class))).thenReturn(futureResultSet);
        when(asyncUtils.transformFuture(futureResultSet, RESULTSET_TO_ROW, executorService)).thenReturn(futureRow);
        when(asyncUtils.transformFuture(eq(futureRow), rowToEntityCaptor.capture(), eq(executorService))).thenReturn(futureEntity);
        when(asyncUtils.transformFuture(eq(futureEntity), isoEntityCaptor.capture(), eq(executorService))).thenReturn(futureEntity);
        when(asyncUtils.buildInterruptible(futureEntity)).thenReturn(achillesFuturesEntity);

        when(mapper.mapRowToEntityWithPrimaryKey(eq(meta), eq(row), Mockito.<Map<String, PropertyMeta>>any(), eq(MANAGED))).thenReturn(entity);
        when(contextFactory.newContext(entity)).thenReturn(context);
        when(proxifier.buildProxyWithAllFieldsLoadedExceptCounters(entity, entityFacade)).thenReturn(entity);

        // When
        final AchillesFuture<CompleteBean> actual = typedQuery.asyncGetFirst(asyncListeners);

        // Then
        assertThat(actual).isSameAs(achillesFuturesEntity);
        verify(asyncUtils).maybeAddAsyncListeners(futureEntity, asyncListeners, executorService);

        final CompleteBean actualEntity = rowToEntityCaptor.getValue().apply(row);
        assertThat(actualEntity).isSameAs(entity);

        final List<Function<CompleteBean, CompleteBean>> captured = isoEntityCaptor.getAllValues();
        final CompleteBean applyTriggers = captured.get(0).apply(entity);
        assertThat(applyTriggers).isSameAs(entity);
        verify(meta.forInterception()).intercept(entity, Event.POST_LOAD);

        final CompleteBean proxifiedEntity = captured.get(1).apply(entity);
        assertThat(proxifiedEntity).isSameAs(entity);
    }
View Full Code Here

Examples of info.archinnov.achilles.internal.metadata.holder.EntityMeta

    public void should_bootstrap_persistence_manager_factory() throws Exception {
        // Given
        List<Class<?>> candidateClasses = Arrays.asList();
        List<Interceptor<?>> interceptors = Arrays.asList();
        Map<Class<?>, EntityMeta> entityMetaMap = ImmutableMap.<Class<?>, EntityMeta>of(CompleteBean.class,
                new EntityMeta());
        ParsingResult parsingResult = new ParsingResult(entityMetaMap, true);
        final ClassLoader classLoader = this.getClass().getClassLoader();

        // When
        when(argumentExtractor.initConfigContext(configMap)).thenReturn(configContext);
View Full Code Here

Examples of info.archinnov.achilles.internal.metadata.holder.EntityMeta

    private EntityMapper mapper = EntityMapper.Singleton.INSTANCE.get();
    private ConsistencyOverrider overrider = ConsistencyOverrider.Singleton.INSTANCE.get();
    private AsyncUtils asyncUtils = AsyncUtils.Singleton.INSTANCE.get();

    public <T> AchillesFuture<T> loadClusteredCounters(final EntityOperations context) {
        final EntityMeta entityMeta = context.getEntityMeta();
        final Object primaryKey = context.getPrimaryKey();

        final ListenableFuture<Row> futureRow = context.getClusteredCounter();
        Function<Row, T> rowToEntity = new Function<Row, T>() {
            @Override
            public T apply(Row row) {
                T entity = null;
                if (row != null) {
                    entity = entityMeta.forOperations().instanciate();
                    entityMeta.getIdMeta().forValues().setValueToField(entity, primaryKey);

                    for (PropertyMeta counterMeta : context.getAllCountersMeta()) {
                        mapper.setCounterToEntity(counterMeta, entity, row);
                    }
                }
View Full Code Here

Examples of info.archinnov.achilles.internal.metadata.holder.EntityMeta

        log.debug("Build meta data for candidate entities");
        Map<Class<?>, EntityMeta> entityMetaMap = new HashMap<>();
        boolean hasSimpleCounter = false;
        for (Class<?> entityClass : entities) {
            EntityParsingContext context = new EntityParsingContext(configContext, entityClass);
            EntityMeta entityMeta = entityParser.parseEntity(context);
            entityMetaMap.put(entityClass, entityMeta);

            hasSimpleCounter = hasSimpleCounter || (context.hasSimpleCounter() && !entityMeta.structure().isClusteredCounter());
            boolean shouldValidateBean = configContext.isClassConstrained(entityClass);
            if (shouldValidateBean) {
                configContext.addBeanValidationInterceptor(entityMeta);
            }
        }
View Full Code Here

Examples of info.archinnov.achilles.internal.metadata.holder.EntityMeta

    public void validateOrCreateTables(SchemaContext schemaContext) {
        log.debug("Start schema validation/creation");
        Map<String, TableMetadata> tableMetaDatas = schemaContext.fetchTableMetaData();

        for (Entry<Class<?>, EntityMeta> entry : schemaContext.entityMetaEntrySet()) {
            EntityMeta entityMeta = entry.getValue();
            final EntityMetaConfig metaConfig = entityMeta.config();
            String qualifiedTableName = metaConfig.getQualifiedTableName().toLowerCase();

            if (tableMetaDatas.containsKey(qualifiedTableName)) {
                TableMetadata tableMetaData = tableMetaDatas.get(qualifiedTableName);
                schemaContext.validateForEntity(entityMeta, tableMetaData);
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.