本文整理汇总了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;
}
示例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);
}
}
示例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);
}
示例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);
}
示例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();
}
示例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);
}
示例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);
}
示例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
);
}
示例9: getObjAttribute
import org.apache.cayenne.map.ObjAttribute; //导入依赖的package包/类
/**
* @return The underlying ObjAttribute fronted by this property adapter.
*/
public ObjAttribute getObjAttribute()
{
return objectAttribute;
}
示例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;
}