当前位置: 首页>>代码示例>>Java>>正文


Java JDOMetadata类代码示例

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


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

示例1: addEntityMetadata

import javax.jdo.metadata.JDOMetadata; //导入依赖的package包/类
@Override
public void addEntityMetadata(JDOMetadata jdoMetadata, EntityDto entity, Class<?> definition, SchemaHolder schemaHolder) {
    String className = (entity.isDDE()) ? entity.getClassName() : ClassName.getEntityClassName(entity.getClassName());
    String packageName = ClassName.getPackage(className);
    String tableName = ClassTableName.getTableName(entity.getClassName(), entity.getModule(), entity.getNamespace(), entity.getTableName(), null);

    PackageMetadata pmd = getPackageMetadata(jdoMetadata, packageName);
    ClassMetadata cmd = getClassMetadata(pmd, ClassName.getSimpleName(ClassName.getEntityClassName(entity.getClassName())));

    cmd.setTable(tableName);
    cmd.setDetachable(true);
    cmd.setIdentityType(IdentityType.APPLICATION);
    cmd.setPersistenceModifier(ClassPersistenceModifier.PERSISTENCE_CAPABLE);

    addInheritanceMetadata(cmd, definition);

    if (!entity.isSubClassOfMdsEntity() && !entity.isSubClassOfMdsVersionedEntity()) {
        addIdField(cmd, entity, schemaHolder, definition);
        //we add versioning metadata only for Standard class.
        addVersioningMetadata(cmd, definition);
    }

    addMetadataForFields(cmd, null, entity, EntityType.STANDARD, definition, schemaHolder);
}
 
开发者ID:motech,项目名称:motech,代码行数:25,代码来源:EntityMetadataBuilderImpl.java

示例2: addHelperClassMetadata

import javax.jdo.metadata.JDOMetadata; //导入依赖的package包/类
@Override
public void addHelperClassMetadata(JDOMetadata jdoMetadata, ClassData classData,
                                   EntityDto entity, EntityType entityType, Class<?> definition,
                                   SchemaHolder schemaHolder) {
    String packageName = ClassName.getPackage(classData.getClassName());
    String simpleName = ClassName.getSimpleName(classData.getClassName());
    String tableName = ClassTableName.getTableName(classData.getClassName(), classData.getModule(), classData.getNamespace(),
            entity == null ? "" : entity.getTableName(), entityType);

    PackageMetadata pmd = getPackageMetadata(jdoMetadata, packageName);
    ClassMetadata cmd = getClassMetadata(pmd, simpleName);

    cmd.setTable(tableName);
    cmd.setDetachable(true);
    cmd.setIdentityType(IdentityType.APPLICATION);
    cmd.setPersistenceModifier(ClassPersistenceModifier.PERSISTENCE_CAPABLE);

    InheritanceMetadata imd = cmd.newInheritanceMetadata();
    imd.setCustomStrategy("complete-table");

    addIdField(cmd, classData.getClassName(), definition);

    if (entity != null) {
        addMetadataForFields(cmd, classData, entity, entityType, definition, schemaHolder);
    }
}
 
开发者ID:motech,项目名称:motech,代码行数:27,代码来源:EntityMetadataBuilderImpl.java

示例3: buildMetadata

import javax.jdo.metadata.JDOMetadata; //导入依赖的package包/类
private void buildMetadata(List<EntityDto> entities, JDOMetadata jdoMetadata, Map<String, ClassData> classDataMap,
                           List<Class> classes, SchemaHolder schemaHolder) {
    for (EntityDto entity : entities) {
        String className = entity.getClassName();
        Class definition = null;

        for (Class clazz : classes) {
            if (clazz.getName().equals(className)) {
                definition = clazz;
                break;
            }
        }

        metadataBuilder.addEntityMetadata(jdoMetadata, entity, definition, schemaHolder);

        if (entity.isRecordHistory()) {
            metadataBuilder.addHelperClassMetadata(jdoMetadata, classDataMap.get(ClassName.getHistoryClassName(className)),
                    entity, EntityType.HISTORY, definition, schemaHolder);
        }

        metadataBuilder.addHelperClassMetadata(jdoMetadata, classDataMap.get(ClassName.getTrashClassName(className)),
                entity, EntityType.TRASH, definition, schemaHolder);
    }
}
 
开发者ID:motech,项目名称:motech,代码行数:25,代码来源:MDSConstructorImpl.java

示例4: fixEnhancerIssuesInMetadata

import javax.jdo.metadata.JDOMetadata; //导入依赖的package包/类
@Override
public void fixEnhancerIssuesInMetadata(JDOMetadata jdoMetadata, SchemaHolder schemaHolder) {
    for (PackageMetadata pmd : jdoMetadata.getPackages()) {
        for (ClassMetadata cmd : pmd.getClasses()) {
            String className = String.format("%s.%s", pmd.getName(), cmd.getName());
            EntityType entityType = EntityType.forClassName(className);

            if (entityType == EntityType.STANDARD) {

                EntityDto entity = schemaHolder.getEntityByClassName(className);

                if (null != entity) {
                    for (MemberMetadata mmd : cmd.getMembers()) {
                        CollectionMetadata collMd = mmd.getCollectionMetadata();
                        FieldDto field = schemaHolder.getFieldByName(entity, mmd.getName());

                        if (null != collMd) {
                            fixCollectionMetadata(collMd, field);
                        }

                        if (null != field && field.getType().isRelationship()) {
                            fixRelationMetadata(pmd, entity, field);
                        }

                        //Defining column name for join and element results in setting it both as XML attribute and child element
                        fixDuplicateColumnDefinitions(mmd);
                    }
                }
            }
        }
    }
}
 
开发者ID:motech,项目名称:motech,代码行数:33,代码来源:EntityMetadataBuilderImpl.java

示例5: getPackageMetadata

import javax.jdo.metadata.JDOMetadata; //导入依赖的package包/类
private static PackageMetadata getPackageMetadata(JDOMetadata jdoMetadata, String packageName) {
    // first look for existing metadata
    PackageMetadata[] packages = jdoMetadata.getPackages();
    if (ArrayUtils.isNotEmpty(packages)) {
        for (PackageMetadata pkgMetadata : packages) {
            if (StringUtils.equals(pkgMetadata.getName(), packageName)) {
                return pkgMetadata;
            }
        }
    }
    // if not found, create new
    return jdoMetadata.newPackageMetadata(packageName);
}
 
开发者ID:motech,项目名称:motech,代码行数:14,代码来源:EntityMetadataBuilderImpl.java

示例6: shouldReturnAndReloadMetadata

import javax.jdo.metadata.JDOMetadata; //导入依赖的package包/类
@Test
public void shouldReturnAndReloadMetadata() {
    JDOMetadata jdoMetadata = mock(JDOMetadata.class);
    when(pmf.newMetadata()).thenReturn(jdoMetadata);

    // constructs initial metadata, then reloads
    assertEquals(jdoMetadata, metadataHolder.getJdoMetadata());
    assertEquals(jdoMetadata, metadataHolder.reloadMetadata());
    verify(pmf, times(2)).newMetadata();

    // retrieves existing metadata
    assertEquals(jdoMetadata, metadataHolder.getJdoMetadata());
    verifyNoMoreInteractions(pmf);
}
 
开发者ID:motech,项目名称:motech,代码行数:15,代码来源:MetadataHolderTest.java

示例7: populate

import javax.jdo.metadata.JDOMetadata; //导入依赖的package包/类
public JDOMetadata populate(JDOMetadata md, String fullyQualifiedClassName, String fieldName) {
    PackageMetadata pmd = md.newPackageMetadata(fullyQualifiedClassName.substring(0, fullyQualifiedClassName.lastIndexOf(".")));
    ClassMetadata cmd = pmd.newClassMetadata(fullyQualifiedClassName.substring(fullyQualifiedClassName.lastIndexOf(".") + 1));

    cmd.setTable(new ClassName(fullyQualifiedClassName).getSimpleName().toLowerCase()).setDetachable(true);
    cmd.setPersistenceModifier(ClassPersistenceModifier.PERSISTENCE_CAPABLE);
    cmd.setIdentityType(IdentityType.APPLICATION);
    cmd.newDatastoreIdentityMetadata().setStrategy(IdGeneratorStrategy.INCREMENT);
    cmd.newInheritanceMetadata().setStrategy(InheritanceStrategy.NEW_TABLE);

    FieldMetadata fmd = cmd.newFieldMetadata(fieldName);
    fmd.setNullValue(NullValue.DEFAULT).setColumn(fieldName);
    return md;
}
 
开发者ID:subhrajitroy,项目名称:osgi-jdo-sample,代码行数:15,代码来源:EntityMetadataFactory.java

示例8: populate

import javax.jdo.metadata.JDOMetadata; //导入依赖的package包/类
public JDOMetadata populate(JDOMetadata md, String fullyQualifiedClassName, String fieldName) {
    String packageName = fullyQualifiedClassName.substring(0, fullyQualifiedClassName.lastIndexOf("."));
    PackageMetadata pmd = md.newPackageMetadata(packageName);
    String className = fullyQualifiedClassName.substring(fullyQualifiedClassName.lastIndexOf(".") + 1);
    ClassMetadata cmd = pmd.newClassMetadata(className);

    cmd.setTable(className.toUpperCase()).setDetachable(true);
    cmd.setIdentityType(IdentityType.DATASTORE);
    cmd.setPersistenceModifier(ClassPersistenceModifier.PERSISTENCE_CAPABLE);

    FieldMetadata fmd = cmd.newFieldMetadata(fieldName);
    fmd.setNullValue(NullValue.DEFAULT).setColumn(fieldName);
    return md;
}
 
开发者ID:subhrajitroy,项目名称:osgi-jdo-sample,代码行数:15,代码来源:ClassMetadataFactory.java

示例9: getJdoMetadata

import javax.jdo.metadata.JDOMetadata; //导入依赖的package包/类
public JDOMetadata getJdoMetadata() {
    if (jdoMetadata == null) {
        jdoMetadata = persistenceManagerFactory.newMetadata();
    }
    return jdoMetadata;
}
 
开发者ID:motech,项目名称:motech,代码行数:7,代码来源:MetadataHolder.java

示例10: reloadMetadata

import javax.jdo.metadata.JDOMetadata; //导入依赖的package包/类
public JDOMetadata reloadMetadata() {
    jdoMetadata = persistenceManagerFactory.newMetadata();
    return jdoMetadata;
}
 
开发者ID:motech,项目名称:motech,代码行数:5,代码来源:MetadataHolder.java

示例11: addBaseMetadata

import javax.jdo.metadata.JDOMetadata; //导入依赖的package包/类
@Override
public void addBaseMetadata(JDOMetadata jdoMetadata, ClassData classData, EntityType entityType, Class<?> definition) {
    addHelperClassMetadata(jdoMetadata, classData, null, entityType, definition, null);
}
 
开发者ID:motech,项目名称:motech,代码行数:5,代码来源:EntityMetadataBuilderImpl.java

示例12: addEntityMetadata

import javax.jdo.metadata.JDOMetadata; //导入依赖的package包/类
/**
 * Adds information about package and class name to a {@link javax.jdo.metadata.JDOMetadata}
 * instance.
 *
 * @param jdoMetadata  a empty instance of {@link javax.jdo.metadata.JDOMetadata}.
 * @param entity       a instance of {@link org.motechproject.mds.domain.Entity}
 * @param definition   the definition of the class
 * @param schemaHolder the holder of the current schema
 */
void addEntityMetadata(JDOMetadata jdoMetadata, EntityDto entity, Class<?> definition, SchemaHolder schemaHolder);
 
开发者ID:motech,项目名称:motech,代码行数:11,代码来源:EntityMetadataBuilder.java

示例13: addBaseMetadata

import javax.jdo.metadata.JDOMetadata; //导入依赖的package包/类
/**
 * Adds base information about package and class name to a
 * {@link javax.jdo.metadata.JDOMetadata} instance.
 *
 * @param jdoMetadata an empty instance of {@link javax.jdo.metadata.JDOMetadata}.
 * @param classData   an instance of {@link org.motechproject.mds.domain.ClassData}
 * @param entityType type of the entity(regular, history or trash)
 * @param definition  the definition of the parent class
 */
void addBaseMetadata(JDOMetadata jdoMetadata, ClassData classData, EntityType entityType, Class<?> definition);
 
开发者ID:motech,项目名称:motech,代码行数:11,代码来源:EntityMetadataBuilder.java

示例14: addHelperClassMetadata

import javax.jdo.metadata.JDOMetadata; //导入依赖的package包/类
/**
 * Creates metadata with basic information about package and class name to the
 * {@link javax.jdo.metadata.JDOMetadata} instance. Additionally, fetches fields
 * from passed entities and adds metadata for fields, if it's necessary. If entity
 * is null, it will work just like <code>addBaseMetadata(JDOMetadata, ClassData)</code>
 * and won't add any metadata for fields.
 *
 * @param jdoMetadata an empty instance of {@link javax.jdo.metadata.JDOMetadata}.
 * @param classData   an instance of {@link org.motechproject.mds.domain.ClassData}
 * @param entity      an entity to fetch fields from
 * @param entityType type of the entity(history or trash)
 * @param definition  the definition of the parent class
 * @param schemaHolder the holder of the current schema
 */
void addHelperClassMetadata(JDOMetadata jdoMetadata, ClassData classData, EntityDto entity,
                            EntityType entityType, Class<?> definition, SchemaHolder schemaHolder);
 
开发者ID:motech,项目名称:motech,代码行数:17,代码来源:EntityMetadataBuilder.java

示例15: fixEnhancerIssuesInMetadata

import javax.jdo.metadata.JDOMetadata; //导入依赖的package包/类
/**
 * This updates the metadata after enhancement. Nucleus makes some "corrections" which do not work with
 * the runtime enhancer.
 * @param jdoMetadata an empty instance of {@link javax.jdo.metadata.JDOMetadata}.
 */
void fixEnhancerIssuesInMetadata(JDOMetadata jdoMetadata, SchemaHolder schemaHolder);
 
开发者ID:motech,项目名称:motech,代码行数:7,代码来源:EntityMetadataBuilder.java


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