• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java ObjEntity类的典型用法和代码示例

java 9次浏览

本文整理汇总了Java中org.apache.cayenne.map.ObjEntity的典型用法代码示例。如果您正苦于以下问题:Java ObjEntity类的具体用法?Java ObjEntity怎么用?Java ObjEntity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

ObjEntity类属于org.apache.cayenne.map包,在下文中一共展示了ObjEntity类的36个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getContextMenu

点赞 3

import org.apache.cayenne.map.ObjEntity; //导入依赖的package包/类
@Override
public ContextMenu getContextMenu()
{
    ContextMenu contextMenu  = new ContextMenu();
    ObjEntity   objectEntity = (ObjEntity) getPropertyAdapter().getWrappedObject();

    getPropertyAdapter().getDataMapAdapter().getDatabaseEntityAdapters().stream().forEach(databaseEntity ->
        {
            if (StringUtils.equals(databaseEntity.getName(), objectEntity.getDbEntityName()))
            {
                MenuItem jumpTo = new MenuItem("Jump To Database Entity: " + databaseEntity.getName());

                jumpTo.setMnemonicParsing(false);
                jumpTo.setOnAction(event ->
                    {
                        LOGGER.debug("Jumping to DB Entity: " + databaseEntity.getName());
                    });

                contextMenu.getItems().add(jumpTo);
            }
        });

  return contextMenu;
}
 

开发者ID:apache,
项目名称:cayenne-modeler,
代码行数:25,
代码来源:ObjectEntityTreeItem.java

示例2: getRelatedDbEntities

点赞 3

import org.apache.cayenne.map.ObjEntity; //导入依赖的package包/类
static Stream<DbEntity> getRelatedDbEntities(EntityResolver resolver, Class<?> entityType, Property<?> relationship) {
    ObjEntity entity = resolver.getObjEntity(entityType);

    if (entity == null) {
        throw new IllegalArgumentException("Not a Cayenne entity class: " + entityType.getName());
    }

    ObjRelationship objRelationship = entity.getRelationship(relationship.getName());

    if (objRelationship == null) {
        throw new IllegalArgumentException("No relationship '" + relationship.getName() + "' in entity " + entityType.getName());
    }

    List<DbRelationship> path = objRelationship.getDbRelationships();
    if (path.size() < 2) {
        return Stream.empty();
    }

    return path.subList(1, path.size()).stream().map(DbRelationship::getSourceEntity);
}
 

开发者ID:bootique,
项目名称:bootique-cayenne,
代码行数:21,
代码来源:CayenneModelUtils.java

示例3: getRelatedTable

点赞 3

import org.apache.cayenne.map.ObjEntity; //导入依赖的package包/类
/**
 * Returns a Table related to a given entity via the specified relationship. Useful for navigation to join tables
 * that are not directly mapped to Java classes.
 *
 * @param entityType   a root entity used to resolve a join table.
 * @param relationship a Property indicating an ObjRelationship.
 * @param tableIndex   An index in a list of tables spanned by 'relationship'. Index of 0 corresponds to the target
 *                     DbEntity of the first object in a chain of DbRelationships for a given ObjRelationship.
 * @return a Table related to a given entity via the specified relationship.
 * @since 0.24
 */
public Table getRelatedTable(Class<?> entityType, Property<?> relationship, int tableIndex) {
    ObjEntity entity = resolver.getObjEntity(entityType);
    if (entity == null) {
        throw new IllegalArgumentException("Not a Cayenne entity class: " + entityType.getName());
    }

    ObjRelationship flattened = entity.getRelationship(relationship.getName());

    if (flattened == null) {
        throw new IllegalArgumentException("No relationship '" + relationship.getName() + "' in entity " + entityType.getName());
    }

    List<DbRelationship> path = flattened.getDbRelationships();

    if (path.size() < tableIndex + 1) {
        throw new IllegalArgumentException("Index " + tableIndex + " is out of bounds for relationship '" + relationship.getName());
    }

    return getTable(path.get(tableIndex).getTargetEntityName());
}
 

开发者ID:bootique,
项目名称:bootique-cayenne,
代码行数:32,
代码来源:CayenneTableManager.java

示例4: DefaultDeleteBuilder

点赞 3

import org.apache.cayenne.map.ObjEntity; //导入依赖的package包/类
public DefaultDeleteBuilder(Class<T> type, ITargetCayenneService targetCayenneService, ITokenManager tokenManager,
		IKeyAdapterFactory keyAdapterFactory, ITaskService taskService, IPathNormalizer pathNormalizer) {

	this.tokenManager = tokenManager;
	this.taskService = taskService;
	this.targetCayenneService = targetCayenneService;
	this.type = type;

	ObjEntity entity = targetCayenneService.entityResolver().getObjEntity(type);
	if (entity == null) {
		throw new LmRuntimeException("Java class " + type.getName() + " is not mapped in Cayenne");
	}

	EntityPathNormalizer entityPathNormalizer = pathNormalizer.normalizer(entity);

	this.mapperBuilder = new MapperBuilder(entity, entityPathNormalizer, keyAdapterFactory);
	this.listenersBuilder = createListenersBuilder();

	// always add stats listener..
	stageListener(DeleteStatsListener.instance());
}
 

开发者ID:nhl,
项目名称:link-move,
代码行数:22,
代码来源:DefaultDeleteBuilder.java

示例5: DefaultCreateOrUpdateBuilder

点赞 3

import org.apache.cayenne.map.ObjEntity; //导入依赖的package包/类
public DefaultCreateOrUpdateBuilder(Class<T> type, ITargetCayenneService targetCayenneService,
		IExtractorService extractorService, ITokenManager tokenManager, IKeyAdapterFactory keyAdapterFactory,
		IPathNormalizer pathNormalizer, ITargetPropertyWriterService writerService) {

	this.type = type;
	this.targetCayenneService = targetCayenneService;
	this.extractorService = extractorService;
	this.tokenManager = tokenManager;

	ObjEntity entity = targetCayenneService.entityResolver().getObjEntity(type);
	if (entity == null) {
		throw new LmRuntimeException("Java class " + type.getName() + " is not mapped in Cayenne");
	}

	this.writerService = writerService;

	this.entityPathNormalizer = pathNormalizer.normalizer(entity);

	this.mapperBuilder = new MapperBuilder(entity, entityPathNormalizer, keyAdapterFactory);
	this.stageListenersBuilder = createListenersBuilder();

	// always add stats listener..
	stageListener(CreateOrUpdateStatsListener.instance());
}
 

开发者ID:nhl,
项目名称:link-move,
代码行数:25,
代码来源:DefaultCreateOrUpdateBuilder.java

示例6: before

点赞 3

import org.apache.cayenne.map.ObjEntity; //导入依赖的package包/类
@Before
public void before() {

	ObjEntity targetEntity = mock(ObjEntity.class);

	EntityResolver resolver = mock(EntityResolver.class);
	when(resolver.getObjEntity(any(Class.class))).thenReturn(targetEntity);

	ITargetCayenneService cayenneService = mock(ITargetCayenneService.class);
	when(cayenneService.entityResolver()).thenReturn(resolver);

	IExtractorService extractorService = mock(IExtractorService.class);
	ITokenManager tokenManager = mock(ITokenManager.class);
	IKeyAdapterFactory keyAdapterFactory = mock(IKeyAdapterFactory.class);

	IPathNormalizer mockPathNormalizer = mock(IPathNormalizer.class);
	ITargetPropertyWriterService writerService = mock(ITargetPropertyWriterService.class);

	taskService = new TaskService(extractorService, cayenneService, tokenManager, keyAdapterFactory,
			mockPathNormalizer, writerService);
}
 

开发者ID:nhl,
项目名称:link-move,
代码行数:22,
代码来源:TaskServiceTest.java

示例7: deleteByParent

点赞 3

import org.apache.cayenne.map.ObjEntity; //导入依赖的package包/类
private <T extends DataObject> void deleteByParent(DeleteContext<T> context, ObjectContext cayenneContext, LrEntity<?> lrParentEntity) {

        EntityParent<?> parent = context.getParent();
        Object parentObject = Util.findById(cayenneContext, parent.getType(), lrParentEntity, parent.getId().get());

        if (parentObject == null) {
            ObjEntity entity = cayenneContext.getEntityResolver().getObjEntity(parent.getType());
            throw new LinkRestException(Response.Status.NOT_FOUND, "No parent object for ID '" + parent.getId()
                    + "' and entity '" + entity.getName() + "'");
        }

        Expression qualifier = parent.qualifier(cayenneContext.getEntityResolver());
        SelectQuery<?> select = SelectQuery.query(context.getType());
        select.andQualifier(qualifier);

        List<?> objects = cayenneContext.select(select);

        cayenneContext.deleteObjects(objects);
        cayenneContext.commitChanges();
    }
 

开发者ID:nhl,
项目名称:link-rest,
代码行数:21,
代码来源:CayenneDeleteStage.java

示例8: setPrimaryKey

点赞 3

import org.apache.cayenne.map.ObjEntity; //导入依赖的package包/类
private void setPrimaryKey(DataObject o, ObjEntity entity, DbAttribute pk, Object id) {

        // 1. meaningful ID
        // TODO: must compile all this... figuring this on the fly is
        // slow
        ObjAttribute opk = entity.getAttributeForDbAttribute(pk);
        if (opk != null) {
            o.writeProperty(opk.getName(), id);
        }
        // 2. PK is auto-generated ... I guess this is sorta
        // expected to fail - generated meaningless PK should not be
        // pushed from the client
        else if (pk.isGenerated()) {
            throw new LinkRestException(Response.Status.BAD_REQUEST, "Can't create '" + entity.getName()
                    + "' with fixed id");
        }
        // 3. probably a propagated ID.
        else {
            // TODO: hopefully this works..
            o.getObjectId().getReplacementIdMap().put(pk.getName(), id);
        }
    }
 

开发者ID:nhl,
项目名称:link-rest,
代码行数:23,
代码来源:CayenneUpdateDataStoreStage.java

示例9: getOptionalExistingObject

点赞 3

import org.apache.cayenne.map.ObjEntity; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private Object getOptionalExistingObject(Class<?> type, ObjectContext context, Object id) {

    ObjEntity entity = context.getEntityResolver().getObjEntity(type);

    // sanity checking...
    if (entity == null) {
        throw new LinkRestException(Response.Status.INTERNAL_SERVER_ERROR, "Unknown entity class: " + type);
    }

    // TODO: should we start using optimistic locking on PK by default
    // instead of SELECT/DELETE|UPDATE?

    String idName = entity.getPrimaryKeyNames().iterator().next();
    ObjectIdQuery select = new ObjectIdQuery(new ObjectId(entity.getName(), idName, id));

    return Cayenne.objectForQuery(context, select);
}
 

开发者ID:nhl,
项目名称:link-rest,
代码行数:19,
代码来源:CayenneUnrelateDataStoreStage.java

示例10: init

点赞 3

import org.apache.cayenne.map.ObjEntity; //导入依赖的package包/类
@Override
public void init(DataChannel channel) {

    // load dynamic attributes and relationships... Will be testing whether LR can handle generic Cayenne properties
    // with no getters/setters.

    ObjEntity e25 = channel.getEntityResolver().getObjEntity(E25.class);
    ObjAttribute dynamicAttribute = new ObjAttribute("name", "java.lang.String", e25);
    dynamicAttribute.setDbAttributePath("name");
    e25.addAttribute(dynamicAttribute);

    ObjEntity e22 = channel.getEntityResolver().getObjEntity(E22.class);
    ObjRelationship e25_e22 = new ObjRelationship("e22");
    e25_e22.setTargetEntityName(e22.getName());
    e25_e22.setSourceEntity(e25);
    e25_e22.setDbRelationshipPath("e22");
    e25.addRelationship(e25_e22);
}
 

开发者ID:nhl,
项目名称:link-rest,
代码行数:19,
代码来源:DynamicModelLoader.java

示例11: testGet_CompoundId_UnmappedPk

点赞 3

import org.apache.cayenne.map.ObjEntity; //导入依赖的package包/类
@Test
public void testGet_CompoundId_UnmappedPk() {

    // remove a part of PK from the ObjEntity
    DataMap dataMap = DB_STACK.getCayenneStack().getChannel().getEntityResolver().getDataMap("datamap");
    ObjEntity E17 = dataMap.getObjEntity("E17");
    ObjAttribute unmappedAttribute = E17.getAttribute("id2");
    E17.removeAttribute("id2");

    insert("e17", "id1, id2, name", "1, 1, 'aaa'");
    insert("e17", "id1, id2, name", "2, 2, 'bbb'");
    insert("e18", "id, e17_id1, e17_id2, name", "1, 1, 1, 'xxx'");
    insert("e18", "id, e17_id1, e17_id2, name", "2, 1, 1, 'yyy'");
    insert("e18", "id, e17_id1, e17_id2, name", "3, 2, 2, 'zzz'");

    Response r1 = target("/e18/1").queryParam("include", E18.E17.getName()).request().get();

    assertEquals(Status.OK.getStatusCode(), r1.getStatus());
    assertEquals("{\"data\":[{\"id\":1,\"" + "e17\":{\"id\":{\"id1\":1,\"id2\":1},\"id1\":1,\"name\":\"aaa\"},"
            + "\"name\":\"xxx\"}],\"total\":1}", r1.readEntity(String.class));

    // restore initial state
    E17.addAttribute(unmappedAttribute);
}
 

开发者ID:nhl,
项目名称:link-rest,
代码行数:25,
代码来源:GET_Related_IT.java

示例12: ObjectEntityAdapter

点赞 2

import org.apache.cayenne.map.ObjEntity; //导入依赖的package包/类
public ObjectEntityAdapter(final ObjEntity objectEntity)
    {
        // Must be assigned before property binding.
        this.objectEntity = objectEntity;

        try
        {
            nameProperty          = bindString(OBJECT_ENTITY_NAME);
            abstractClassProperty = bindBoolean(ABSTRACT_CLASS);


//            locationProperty = JavaBeanStringPropertyBuilder.create().bean(dataMap).name("map").build();

//            quoteSQLIdentifiersProperty = JavaBeanBooleanPropertyBuilder.create().bean(dataMap).name(DataMap.DEFAULT_QUOTE_SQL_IDENTIFIERS_PROPERTY).build();

//            defaultCatalogProperty = JavaBeanStringPropertyBuilder.create().bean(dataMap).name(DataMap.DEFAULT_CATALOG_PROPERTY).build();
//            defaultSchemaProperty  = JavaBeanStringPropertyBuilder.create().bean(dataMap).name(DataMap.DEFAULT_SCHEMA_PROPERTY).build();
//            defaultPackageProperty = JavaBeanStringPropertyBuilder.create().bean(dataMap).name(DataMap.DEFAULT_PACKAGE_PROPERTY).build();
//
//            defaultSuperclassProperty = JavaBeanStringPropertyBuilder.create().bean(dataMap).name(DataMap.DEFAULT_SUPERCLASS_PROPERTY).build();
//            defaultLockTypeProperty   = JavaBeanIntegerPropertyBuilder.create().bean(dataMap).name(DataMap.DEFAULT_LOCK_TYPE_PROPERTY).build();
//
//            clientSupportedProperty         = JavaBeanBooleanPropertyBuilder.create().bean(dataMap).name(DataMap.CLIENT_SUPPORTED_PROPERTY).build();
//            defaultClientPackageProperty    = JavaBeanStringPropertyBuilder.create().bean(dataMap).name(DataMap.DEFAULT_CLIENT_PACKAGE_PROPERTY).build();
//            defaultClientSuperclassProperty = JavaBeanStringPropertyBuilder.create().bean(dataMap).name(DataMap.DEFAULT_CLIENT_SUPERCLASS_PROPERTY).build();
        }
        catch (final NoSuchMethodException e)
        {
            throw new RuntimeException("Fix the builder.", e);
        }

        objectEntity.getAttributes().stream().forEach(objAttribute -> objectAttributeAdapters.add(new ObjectAttributeAdapter(objAttribute)));

        objectAttributeAdapters.stream().forEach(objectAttributeAdapter -> objectAttributeAdapter.setObjectEntityAdapter(this));
    }
 

开发者ID:apache,
项目名称:cayenne-modeler,
代码行数:36,
代码来源:ObjectEntityAdapter.java

示例13: getPkName

点赞 2

import org.apache.cayenne.map.ObjEntity; //导入依赖的package包/类
/**
 * Return the database primary key column name for the given data object.
 *
 * @param dataObjectClass the class of the data object
 * @return the primary key column name
 */
protected String getPkName(Class dataObjectClass) {
    Validate.notNull(dataObjectClass, "Null dataObjectClass parameter.");

    ObjEntity objEntity =
            getDataContext().getEntityResolver().lookupObjEntity(dataObjectClass);

    if (objEntity == null) {
        throw new CayenneRuntimeException("Unmapped DataObject Class: "
                + dataObjectClass.getName());
    }

    DbEntity dbEntity = objEntity.getDbEntity();
    if (dbEntity == null) {
        throw new CayenneRuntimeException("No DbEntity for ObjEntity: "
                + objEntity.getName());
    }

    List pkAttributes = dbEntity.getPrimaryKey();
    if (pkAttributes.size() != 1) {
        throw new CayenneRuntimeException("PK contains "
                + pkAttributes.size()
                + " columns, expected 1.");
    }

    DbAttribute attr = (DbAttribute) pkAttributes.get(0);

    return attr.getName();
}
 

开发者ID:florinpatrascu,
项目名称:jpublish,
代码行数:35,
代码来源:CayenneTemplate.java

示例14: getDbEntity

点赞 2

import org.apache.cayenne.map.ObjEntity; //导入依赖的package包/类
static DbEntity getDbEntity(EntityResolver resolver, Class<?> entityType) {
    ObjEntity entity = resolver.getObjEntity(entityType);

    if (entity == null) {
        throw new IllegalArgumentException("Not a Cayenne entity class: " + entityType.getName());
    }

    if (entity.getDbEntityName() == null) {
        throw new IllegalArgumentException("Cayenne entity class is not mapped to a DbEntity: " + entityType.getName());
    }

    return entity.getDbEntity();
}
 

开发者ID:bootique,
项目名称:bootique-cayenne,
代码行数:14,
代码来源:CayenneModelUtils.java

示例15: getTable

点赞 2

import org.apache.cayenne.map.ObjEntity; //导入依赖的package包/类
public Table getTable(Class<?> entityType) {
    ObjEntity entity = resolver.getObjEntity(entityType);
    if (entity == null) {
        throw new IllegalArgumentException("Not a Cayenne entity class: " + entityType.getName());
    }

    if (entity.getDbEntityName() == null) {
        throw new IllegalArgumentException("Cayenne entity class is not mapped to a DbEntity: " + entityType.getName());
    }

    return getTable(entity.getDbEntityName());
}
 

开发者ID:bootique,
项目名称:bootique-cayenne,
代码行数:13,
代码来源:CayenneTableManager.java

示例16: MapperBuilder

点赞 2

import org.apache.cayenne.map.ObjEntity; //导入依赖的package包/类
public MapperBuilder(ObjEntity entity, EntityPathNormalizer pathNormalizer, IKeyAdapterFactory keyAdapterFactory) {
	this.entity = entity;
	this.keyAdapterFactory = keyAdapterFactory;
	this.pathNormalizer = pathNormalizer;

	// Set will weed out simple duplicates , however we don't check for
	// invariants... so duplication is possible via db: vs obj: expressions
	this.paths = new HashSet<>();
}
 

开发者ID:nhl,
项目名称:link-move,
代码行数:10,
代码来源:MapperBuilder.java

示例17: before

点赞 2

import org.apache.cayenne.map.ObjEntity; //导入依赖的package包/类
@Before
public void before() {

	ObjAttribute matchAttribute = new ObjAttribute("abc");
	matchAttribute.setType(Object.class.getName());

	ObjEntity targetEntity = new ObjEntity();
	targetEntity.addAttribute(matchAttribute);

	EntityResolver resolver = mock(EntityResolver.class);
	when(resolver.getObjEntity(any(Class.class))).thenReturn(targetEntity);

	ITargetCayenneService cayenneService = mock(ITargetCayenneService.class);
	when(cayenneService.entityResolver()).thenReturn(resolver);

	IKeyAdapterFactory keyAdapterFactory = mock(IKeyAdapterFactory.class);

	EntityPathNormalizer mockEntityPathNormalizer = mock(EntityPathNormalizer.class);

	IPathNormalizer mockPathNormalizer = mock(IPathNormalizer.class);
	when(mockPathNormalizer.normalizer(targetEntity)).thenReturn(mockEntityPathNormalizer);

	ITaskService taskService = mock(ITaskService.class);
	when(taskService.extractSourceKeys(Etl1t.class)).thenReturn(new DefaultSourceKeysBuilder(
			mockEntityPathNormalizer, mock(IExtractorService.class), mock(ITokenManager.class), keyAdapterFactory));

	this.builder = new DefaultDeleteBuilder<>(Etl1t.class, cayenneService, null, keyAdapterFactory, taskService,
			mockPathNormalizer);
}
 

开发者ID:nhl,
项目名称:link-move,
代码行数:30,
代码来源:DefaultDeleteBuilderTest.java

示例18: before

点赞 2

import org.apache.cayenne.map.ObjEntity; //导入依赖的package包/类
@Before
public void before() {

	ObjEntity e = mock(ObjEntity.class);
	EntityPathNormalizer pathNormalizer = mock(EntityPathNormalizer.class);
	when(pathNormalizer.normalize("a")).thenReturn("db:a");
	when(pathNormalizer.normalize("b")).thenReturn("db:b");
	when(pathNormalizer.normalize("c")).thenReturn("db:c");

	builder = new MapperBuilder(e, pathNormalizer, new KeyAdapterFactory());
}
 

开发者ID:nhl,
项目名称:link-move,
代码行数:12,
代码来源:MapperBuilderTest.java

示例19: before

点赞 2

import org.apache.cayenne.map.ObjEntity; //导入依赖的package包/类
@Before
public void before() {

    ObjAttribute matchAttribute = new ObjAttribute("abc");
    matchAttribute.setType(Object.class.getName());

    ObjEntity targetEntity = new ObjEntity();
    targetEntity.addAttribute(matchAttribute);

    EntityResolver resolver = mock(EntityResolver.class);
    when(resolver.getObjEntity(any(Class.class))).thenReturn(targetEntity);

    ITargetCayenneService cayenneService = mock(ITargetCayenneService.class);
    when(cayenneService.entityResolver()).thenReturn(resolver);

    IKeyAdapterFactory keyAdapterFactory = mock(IKeyAdapterFactory.class);

    EntityPathNormalizer mockEntityPathNormalizer = mock(EntityPathNormalizer.class);

    IPathNormalizer mockPathNormalizer = mock(IPathNormalizer.class);
    when(mockPathNormalizer.normalizer(targetEntity)).thenReturn(mockEntityPathNormalizer);

    ITokenManager mockTokenManager = mock(ITokenManager.class);

    ITargetPropertyWriterService mockWriterService = mock(ITargetPropertyWriterService.class);

    this.builder = new DefaultCreateOrUpdateBuilder<>(Etl1t.class, cayenneService, null,
            mockTokenManager,
            keyAdapterFactory,
            mockPathNormalizer,
            mockWriterService
    );
}
 

开发者ID:nhl,
项目名称:link-move,
代码行数:34,
代码来源:DefaultCreateOrUpdateBuilderTest.java

示例20: before

点赞 2

import org.apache.cayenne.map.ObjEntity; //导入依赖的package包/类
@Before
public void before() {

	ObjEntity mockEntity = mock(ObjEntity.class);
	when(mockEntity.getName()).thenReturn("me");

	EntityResolver resolver = mock(EntityResolver.class);
	when(resolver.getObjEntity(any(Class.class))).thenReturn(mockEntity);

	DataChannel channel = mock(DataChannel.class);
	when(channel.getEntityResolver()).thenReturn(resolver);

	this.cayenneRuntime = mock(ServerRuntime.class);
	when(cayenneRuntime.getChannel()).thenReturn(channel);
}
 

开发者ID:nhl,
项目名称:link-move,
代码行数:16,
代码来源:LmRuntimeBuilderTest.java

示例21: before

点赞 2

import org.apache.cayenne.map.ObjEntity; //导入依赖的package包/类
@Before
public void before() {
	this.cayenneService = new TargetCayenneService(targetStack.runtime());

	EntityPathNormalizer mockEntityPathNormalizer = mock(EntityPathNormalizer.class);

	this.mockPathNormalizer = mock(IPathNormalizer.class);
	when(mockPathNormalizer.normalizer(any(ObjEntity.class))).thenReturn(mockEntityPathNormalizer);
}
 

开发者ID:nhl,
项目名称:link-move,
代码行数:10,
代码来源:DefaultCreateOrUpdateBuilderIT.java

示例22: qualifier

点赞 2

import org.apache.cayenne.map.ObjEntity; //导入依赖的package包/类
public Expression qualifier(EntityResolver resolver) {

		ObjEntity parentEntity = resolver.getObjEntity(type);
		ObjRelationship objRelationship = parentEntity.getRelationship(relationship);

		if (objRelationship == null) {
			throw new LinkRestException(Status.BAD_REQUEST, "Invalid relationship: '" + relationship + "'");
		}

		// navigate through DbRelationships ... there may be no reverse
		// ObjRel.. Reverse DB should always be there

		if (id.size() > 1) {
			List<Expression> expressions = new ArrayList<>();
			for (DbRelationship dbRelationship : objRelationship.getDbRelationships()) {
				DbRelationship reverseRelationship = dbRelationship.getReverseRelationship();
				for (DbJoin join : reverseRelationship.getJoins()) {
					Object joinValue = id.get(join.getTargetName());
					if (joinValue == null) {
						throw new LinkRestException(Status.BAD_REQUEST,
								"Failed to build a Cayenne qualifier for a by-parent relationship '" + relationship +
										"'; one of the parent's ID parts is missing in it's ID: " + join.getTargetName());
					}
					expressions.add(ExpressionFactory.matchDbExp(join.getSourceName(), joinValue));
				}
			}
			return ExpressionFactory.and(expressions);
		} else {
			return ExpressionFactory.matchDbExp(objRelationship.getReverseDbRelationshipPath(), id.get());
		}
	}
 

开发者ID:nhl,
项目名称:link-rest,
代码行数:32,
代码来源:EntityParent.java

示例23: compile

点赞 2

import org.apache.cayenne.map.ObjEntity; //导入依赖的package包/类
@Override
public <T> LrEntity<T> compile(Class<T> type, LrDataMap dataMap) {

    ObjEntity objEntity = resolver.getObjEntity(type);
    if (objEntity == null) {
        return null;
    }
    return new LazyLrPersistentEntity<>(type, () -> doCompile(type, dataMap));
}
 

开发者ID:nhl,
项目名称:link-rest,
代码行数:10,
代码来源:CayenneEntityCompiler.java

示例24: doCompile

点赞 2

import org.apache.cayenne.map.ObjEntity; //导入依赖的package包/类
private <T> LrPersistentEntity<T> doCompile(Class<T> type, LrDataMap dataMap) {

        LOGGER.debug("compiling Cayenne entity for type: " + type);

        ObjEntity objEntity = resolver.getObjEntity(type);
        CayenneLrEntity<T> lrEntity = new CayenneLrEntity<>(type, objEntity);
        loadCayenneEntity(lrEntity, dataMap);
        loadAnnotatedProperties(lrEntity, dataMap);
        loadOverlays(dataMap, lrEntity);
        return lrEntity;
    }
 

开发者ID:nhl,
项目名称:link-rest,
代码行数:12,
代码来源:CayenneEntityCompiler.java

示例25: resolveProperty

点赞 2

import org.apache.cayenne.map.ObjEntity; //导入依赖的package包/类
@Override
public Object resolveProperty(Object baseObject, String propertyName) {

	Persistent persistentBaseObject = (Persistent) baseObject;

	ObjEntity entity = cayenneService.entityResolver().getObjEntity(persistentBaseObject);
	PropertyDescriptor property = cayenneService.entityResolver().getClassDescriptor(entity.getName())
			.getProperty(propertyName);
	return property.readProperty(baseObject);
}
 

开发者ID:nhl,
项目名称:link-rest,
代码行数:11,
代码来源:CayennePointerContext.java

示例26: deleteById

点赞 2

import org.apache.cayenne.map.ObjEntity; //导入依赖的package包/类
private <T extends DataObject> void deleteById(DeleteContext<T> context, ObjectContext cayenneContext, LrEntity<T> lrEntity) {

        for (LrObjectId id : context.getIds()) {
            Object o = Util.findById(cayenneContext, context.getType(), lrEntity, id.get());

            if (o == null) {
                ObjEntity entity = cayenneContext.getEntityResolver().getObjEntity(context.getType());
                throw new LinkRestException(Response.Status.NOT_FOUND, "No object for ID '" + id + "' and entity '"
                        + entity.getName() + "'");
            }

            cayenneContext.deleteObject(o);
        }
        cayenneContext.commitChanges();
    }
 

开发者ID:nhl,
项目名称:link-rest,
代码行数:16,
代码来源:CayenneDeleteStage.java

示例27: deleteAll

点赞 2

import org.apache.cayenne.map.ObjEntity; //导入依赖的package包/类
private <T extends DataObject> void deleteAll(DeleteContext<?> context, ObjectContext cayenneContext) {
    ObjEntity e = cayenneContext.getEntityResolver().getObjEntity(context.getType());

    // TODO: is this kosher? All other deletes are done via Cayenne and
    // hence process all delete rules. This one does not
    cayenneContext.performQuery(new EJBQLQuery("delete from " + e.getName()));
}
 

开发者ID:nhl,
项目名称:link-rest,
代码行数:8,
代码来源:CayenneDeleteStage.java

示例28: findById

点赞 2

import org.apache.cayenne.map.ObjEntity; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static <A> A findById(ObjectContext context, Class<A> type, LrEntity<?> lrEntity, Object id) {
	ObjEntity entity = context.getEntityResolver().getObjEntity(type);

	// sanity checking...
	if (entity == null) {
		throw new LinkRestException(Status.INTERNAL_SERVER_ERROR, "Unknown entity class: " + type);
	}

	if (id == null) {
		throw new LinkRestException(Status.BAD_REQUEST, "No id specified");
	}

	if (id instanceof Map) {
		Map<String, Object> ids = (Map<String, Object>) id;
		ObjectSelect<A> query = ObjectSelect.query(type);
		for (Map.Entry<String, Object> entry : ids.entrySet()) {
			query.and(ExpressionFactory.matchDbExp(
					entity.getDbEntity().getAttribute(entry.getKey()).getName(), entry.getValue()
			));
		}
		return query.selectOne(context);
	} else {
		LrAttribute attribute = lrEntity.getIds().iterator().next();
		return ObjectSelect.query(type, new ASTEqual(attribute.getPathExp(), id)).selectOne(context);
	}
}
 

开发者ID:nhl,
项目名称:link-rest,
代码行数:28,
代码来源:Util.java

示例29: getExistingObject

点赞 2

import org.apache.cayenne.map.ObjEntity; //导入依赖的package包/类
private Object getExistingObject(Class<?> type, ObjectContext context, Object id) {

        Object object = getOptionalExistingObject(type, context, id);
        if (object == null) {
            ObjEntity entity = context.getEntityResolver().getObjEntity(type);
            throw new LinkRestException(Response.Status.NOT_FOUND, "No object for ID '" + id + "' and entity '"
                    + entity.getName() + "'");
        }

        return object;
    }
 

开发者ID:nhl,
项目名称:link-rest,
代码行数:12,
代码来源:CayenneUnrelateDataStoreStage.java

示例30: before

点赞 2

import org.apache.cayenne.map.ObjEntity; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Before
public void before() {

	List<EntityConstraint> r = new ArrayList<>();
	r.add(new DefaultEntityConstraint("E1", true, false, Collections.singleton(E1.AGE.getName()),
			Collections.<String> emptySet()));

	List<EntityConstraint> w = new ArrayList<>();
	w.add(new DefaultEntityConstraint("E2", false, false, Collections.singleton(E2.ADDRESS.getName()),
			Collections.<String> emptySet()));

	ObjEntity e1 = runtime.getChannel().getEntityResolver().getObjEntity(E1.class);
	ObjEntity e2 = runtime.getChannel().getEntityResolver().getObjEntity(E2.class);

	lre1 = mock(LrPersistentEntity.class);
	when(lre1.getObjEntity()).thenReturn(e1);
	when(lre1.getType()).thenReturn(E1.class);
	when(lre1.getName()).thenReturn(e1.getName());

	lre2 = mock(LrPersistentEntity.class);
	when(lre2.getObjEntity()).thenReturn(e2);
	when(lre2.getType()).thenReturn(E2.class);
	when(lre2.getName()).thenReturn(e2.getName());

	this.constraintHandler = new ConstraintsHandler(r, w);
}
 

开发者ID:nhl,
项目名称:link-rest,
代码行数:28,
代码来源:ConstraintsHandlerWithDefaultsTest.java

示例31: ObjectEntityTreeViewModel

点赞 2

import org.apache.cayenne.map.ObjEntity; //导入依赖的package包/类
public ObjectEntityTreeViewModel(final ObjEntity objEntity)
{
    this.objEntity = objEntity;
}
 

开发者ID:apache,
项目名称:cayenne-modeler,
代码行数:5,
代码来源:ObjectEntityTreeViewModel.java

示例32: getValue

点赞 2

import org.apache.cayenne.map.ObjEntity; //导入依赖的package包/类
public ObjEntity getValue()
{
    return objEntity;
}
 

开发者ID:apache,
项目名称:cayenne-modeler,
代码行数:5,
代码来源:ObjectEntityTreeViewModel.java

示例33: display

点赞 2

import org.apache.cayenne.map.ObjEntity; //导入依赖的package包/类
@Deprecated // Unused?
public void display(final ObjEntity objEntity)
{
    LOGGER.debug("trying to display: " + objEntity);
}
 

开发者ID:mrg,
项目名称:CMP,
代码行数:6,
代码来源:ObjectEntityLayout.java

示例34: getObjectForPK

点赞 2

import org.apache.cayenne.map.ObjEntity; //导入依赖的package包/类
/**
 * Perform a query returning the data object specified by the
 * class and the primary key value. If the refresh parameter is true a
 * database query will be performed, otherwise the a query against the
 * object cache will be performed first.
 *
 * @param dataObjectClass the data object class to retrieve
 * @param id              the data object primary key
 * @param refresh         the refresh the object cache mode
 * @return the data object for the given class and id
 */
protected DataObject getObjectForPK(Class dataObjectClass, Object id, boolean refresh) {
    Validate.notNull(dataObjectClass, "Null dataObjectClass parameter.");

    ObjEntity objEntity =
            getDataContext().getEntityResolver().lookupObjEntity(dataObjectClass);

    if (objEntity == null) {
        throw new CayenneRuntimeException("Unmapped DataObject Class: "
                + dataObjectClass.getName());
    }

    String pkName = getPkName(dataObjectClass);

    ObjectId objectId = new ObjectId(objEntity.getName(), pkName, id);

    int refreshMode = (refresh) ? ObjectIdQuery.CACHE_REFRESH : ObjectIdQuery.CACHE;

    ObjectIdQuery objectIdQuery = new ObjectIdQuery(objectId, false, refreshMode);

    return (DataObject) DataObjectUtils.objectForQuery(getDataContext(), objectIdQuery);
}
 

开发者ID:florinpatrascu,
项目名称:jpublish,
代码行数:33,
代码来源:CayenneTemplate.java

示例35: TargetPropertyWriterFactory

点赞 2

import org.apache.cayenne.map.ObjEntity; //导入依赖的package包/类
public TargetPropertyWriterFactory(Class<T> type, ObjEntity entity) {
    this.type = type;
    this.entity = entity;
}
 

开发者ID:nhl,
项目名称:link-move,
代码行数:5,
代码来源:TargetPropertyWriterFactory.java

示例36: extractSourceKeys

点赞 2

import org.apache.cayenne.map.ObjEntity; //导入依赖的package包/类
@Override
public <T extends DataObject> SourceKeysBuilder extractSourceKeys(Class<T> type) {
	ObjEntity targetEntity = targetCayenneService.entityResolver().getObjEntity(type);
	return new DefaultSourceKeysBuilder(pathNormalizer.normalizer(targetEntity), extractorService, tokenManager,
			keyAdapterFactory);
}
 

开发者ID:nhl,
项目名称:link-move,
代码行数:7,
代码来源:TaskService.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)