• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ObjAttribute类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: fakeObjAttribute

import org.apache.cayenne.map.ObjAttribute; //导入依赖的package包/类
private static ObjAttribute fakeObjAttribute(String name, DbAttribute dbAttribute) {
	ObjAttribute a = new ObjAttribute(name) {
		@Override
		public DbAttribute getDbAttribute() {
			return dbAttribute;
		}
	};
	a.setDbAttributePath(dbAttribute.getName());

	String javaType = TypesMapping.getJavaBySqlType(dbAttribute.getType());
	if (javaType == null) {
		throw new NullPointerException("Java type not found for SQL type: " + dbAttribute.getType());
	}
	a.setType(javaType);
	return a;
}
 
开发者ID:nhl,项目名称:link-rest,代码行数:17,代码来源:CayenneLrDbAttribute.java


示例2: setPrimaryKey

import org.apache.cayenne.map.ObjAttribute; //导入依赖的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


示例3: init

import org.apache.cayenne.map.ObjAttribute; //导入依赖的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


示例4: testGet_CompoundId_UnmappedPk

import org.apache.cayenne.map.ObjAttribute; //导入依赖的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


示例5: ObjectAttributeAdapter

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

        try
        {
            nameProperty                  = bindString(OBJECT_ATTRIBUTE_NAME);
            javaTypeProperty              = bindString(OBJECT_ATTRIBUTE_TYPE);
            databaseAttributePathProperty = bindString(DATABASE_ATTRIBUTE_PATH);
            usedForLockingProperty        = bindBoolean(USED_FOR_LOCKING);


//            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);
        }

//        objectAttribute.getDbAttribute().getName();
    }
 
开发者ID:apache,项目名称:cayenne-modeler,代码行数:36,代码来源:ObjectAttributeAdapter.java


示例6: createSafeKeyMapper

import org.apache.cayenne.map.ObjAttribute; //导入依赖的package包/类
@SuppressWarnings("deprecation")
Mapper createSafeKeyMapper(Mapper unsafe) {
	KeyAdapter keyAdapter;

	if (paths.size() > 1) {
		// TODO: mapping keyMapAdapters by type doesn't take into account
		// composition and hierarchy of the keys ... need a different
		// approach. for now resorting to the hacks below

		keyAdapter = keyAdapterFactory.adapter(List.class);
	} else {

		Object attributeOrRelationship = ExpressionFactory.exp(paths.iterator().next()).evaluate(entity);

		Class<?> type;

		if (attributeOrRelationship instanceof ObjAttribute) {
			type = ((ObjAttribute) attributeOrRelationship).getJavaClass();
		} else if (attributeOrRelationship instanceof ObjRelationship) {
			type = ((ObjRelationship) attributeOrRelationship).getTargetEntity().getJavaClass();
		} else {
			type = null;
		}

		keyAdapter = keyAdapterFactory.adapter(type);
	}

	return new SafeMapKeyMapper(unsafe, keyAdapter);
}
 
开发者ID:nhl,项目名称:link-move,代码行数:30,代码来源:MapperBuilder.java


示例7: before

import org.apache.cayenne.map.ObjAttribute; //导入依赖的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


示例8: before

import org.apache.cayenne.map.ObjAttribute; //导入依赖的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


示例9: getObjAttribute

import org.apache.cayenne.map.ObjAttribute; //导入依赖的package包/类
/**
 * @return The underlying ObjAttribute fronted by this property adapter.
 */
public ObjAttribute getObjAttribute()
{
    return objectAttribute;
}
 
开发者ID:apache,项目名称:cayenne-modeler,代码行数:8,代码来源:ObjectAttributeAdapter.java


示例10: CayenneLrAttribute

import org.apache.cayenne.map.ObjAttribute; //导入依赖的package包/类
/**
 * @since 1.24
 */
public CayenneLrAttribute(ObjAttribute objAttribute, Class<?> type) {
	super(objAttribute.getName(), type);
	this.objAttribute = objAttribute;
}
 
开发者ID:nhl,项目名称:link-rest,代码行数:8,代码来源:CayenneLrAttribute.java



注:本文中的org.apache.cayenne.map.ObjAttribute类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CategoryQuestionLiteVoCollection类代码示例发布时间:2022-05-15
下一篇:
Java Status类代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap