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


Java AssociationsModel类代码示例

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


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

示例1: addAssociations

import org.litepal.tablemanager.model.AssociationsModel; //导入依赖的package包/类
/**
 * Analyzing all the association models in the collection. Judge their
 * association types. If it's one2one or many2one associations, add the
 * foreign key column to the associated table. If it's many2many
 * associations, create an intermediate join table.
 * 
 * @param associatedModels
 *            A collection contains all the association models.Use the
 *            association models to get association type and associated
 *            table names.
 * @param db
 *            Instance of SQLiteDatabase.
 * @param force
 *            Drop the table first if it already exists.
 */
private void addAssociations(Collection<AssociationsModel> associatedModels, SQLiteDatabase db,
		boolean force) {
	for (AssociationsModel associationModel : associatedModels) {
		if (Const.Model.MANY_TO_ONE == associationModel.getAssociationType()
				|| Const.Model.ONE_TO_ONE == associationModel.getAssociationType()) {
			addForeignKeyColumn(associationModel.getTableName(),
					associationModel.getAssociatedTableName(),
					associationModel.getTableHoldsForeignKey(), db);
		} else if (Const.Model.MANY_TO_MANY == associationModel.getAssociationType()) {
			createIntermediateTable(associationModel.getTableName(),
					associationModel.getAssociatedTableName(), db, force);
		}
	}
       for (GenericModel genericModel : getGenericModels()) {
           createGenericTable(genericModel, db, force);
       }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:33,代码来源:AssociationCreator.java

示例2: findIntermediateTablesToDrop

import org.litepal.tablemanager.model.AssociationsModel; //导入依赖的package包/类
/**
 * When many2many associations are no longer exist between two models, the
 * intermediate join table should be dropped from database. This method
 * helps find out those intermediate join tables which should be dropped
 * cause their associations in classes are done.
 * 
 * @return A list with all intermediate join tables to drop.
 */
private List<String> findIntermediateTablesToDrop() {
	List<String> intermediateTables = new ArrayList<String>();
	for (String tableName : DBUtility.findAllTableNames(mDb)) {
		if (DBUtility.isIntermediateTable(tableName, mDb)) {
			boolean dropIntermediateTable = true;
			for (AssociationsModel associationModel : mAssociationModels) {
				if (associationModel.getAssociationType() == Const.Model.MANY_TO_MANY) {
					String intermediateTableName = DBUtility.getIntermediateTableName(
							associationModel.getTableName(),
							associationModel.getAssociatedTableName());
					if (tableName.equalsIgnoreCase(intermediateTableName)) {
						dropIntermediateTable = false;
					}
				}
			}
			if (dropIntermediateTable) {
				// drop the intermediate join table
				intermediateTables.add(tableName);
			}
		}
	}
	LogUtil.d(TAG, "findIntermediateTablesToDrop >> " + intermediateTables);
	return intermediateTables;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:33,代码来源:AssociationUpdater.java

示例3: shouldDropForeignKey

import org.litepal.tablemanager.model.AssociationsModel; //导入依赖的package包/类
/**
 * Judge if the current iterated foreign key column should be dropped. It is
 * only used in {@link #findForeignKeyToRemove(org.litepal.tablemanager.model.TableModel)} when iterating
 * the foreign key column list. When this foreign key can not be found in
 * the association model collection, this foreign key should be dropped.
 * 
 * @param selfTableName
 *            The table name of currently table model.
 * @param associatedTableName
 *            The associated table name of current table model.
 * @return If the foreign key currently iterated should be dropped, return
 *         true. Otherwise return false.
 */
private boolean shouldDropForeignKey(String selfTableName, String associatedTableName) {
	for (AssociationsModel associationModel : mAssociationModels) {
		if (associationModel.getAssociationType() == Const.Model.ONE_TO_ONE) {
			if (selfTableName.equalsIgnoreCase(associationModel.getTableHoldsForeignKey())) {
				if (associationModel.getTableName().equalsIgnoreCase(selfTableName)) {
					if (isRelationCorrect(associationModel, selfTableName, associatedTableName)) {
						return false;
					}
				} else if (associationModel.getAssociatedTableName().equalsIgnoreCase(
						selfTableName)) {
					if (isRelationCorrect(associationModel, associatedTableName, selfTableName)) {
						return false;
					}
				}
			}
		} else if (associationModel.getAssociationType() == Const.Model.MANY_TO_ONE) {
			if (isRelationCorrect(associationModel, associatedTableName, selfTableName)) {
				return false;
			}
		}
	}
	return true;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:37,代码来源:AssociationUpdater.java

示例4: getAllAssociations

import org.litepal.tablemanager.model.AssociationsModel; //导入依赖的package包/类
/**
 * This method is used to get all the association models which in the
 * mapping list of litepal.xml file.
 * 
 * @return Collection of RelationModel for all the mapping classes.
 */
protected Collection<AssociationsModel> getAllAssociations() {
	if (mAllRelationModels == null || mAllRelationModels.isEmpty()) {
		mAllRelationModels = getAssociations(LitePalAttr.getInstance().getClassNames());
	}
	return mAllRelationModels;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:Generator.java

示例5: getAssociations

import org.litepal.tablemanager.model.AssociationsModel; //导入依赖的package包/类
/**
 * This method is used to get association models depends on the given class
 * name list.
 * 
 * @param classNames
 *            The names of the classes that want to get their associations.
 * @return Collection of association models.
 */
protected Collection<AssociationsModel> getAssociations(List<String> classNames) {
	if (mAssociationModels == null) {
		mAssociationModels = new HashSet<AssociationsModel>();
	}
       if (mGenericModels == null) {
           mGenericModels = new HashSet<GenericModel>();
       }
	mAssociationModels.clear();
       mGenericModels.clear();
	for (String className : classNames) {
		analyzeClassFields(className, GET_ASSOCIATIONS_ACTION);
	}
	return mAssociationModels;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:LitePalBase.java

示例6: getAssociations

import org.litepal.tablemanager.model.AssociationsModel; //导入依赖的package包/类
/**
 * This method is used to get association models depends on the given class
 * name list.
 * 
 * @param classNames
 *            The names of the classes that want to get their associations.
 * @return Collection of association models.
 */
protected Collection<AssociationsModel> getAssociations(List<String> classNames) {
	if (mAssociationModels == null) {
		mAssociationModels = new HashSet<AssociationsModel>();
	}
	mAssociationModels.clear();
	for (String className : classNames) {
		analyzeClassFields(className, GET_ASSOCIATIONS_ACTION);
	}
	return mAssociationModels;
}
 
开发者ID:ownwell,项目名称:zztinews,代码行数:19,代码来源:LitePalBase.java

示例7: addIntoAssociationModelCollection

import org.litepal.tablemanager.model.AssociationsModel; //导入依赖的package包/类
/**
 * Package a {@link org.litepal.tablemanager.model.AssociationsModel}, and add it into
 * {@link #mAssociationModels} Collection.
 * 
 * @param className
 *            The class name for {@link org.litepal.tablemanager.model.AssociationsModel}.
 * @param associatedClassName
 *            The associated class name for {@link org.litepal.tablemanager.model.AssociationsModel}.
 * @param classHoldsForeignKey
 *            The class which holds foreign key.
 * @param associationType
 *            The association type for {@link org.litepal.tablemanager.model.AssociationsModel}.
 */
private void addIntoAssociationModelCollection(String className, String associatedClassName,
		String classHoldsForeignKey, int associationType) {
	AssociationsModel associationModel = new AssociationsModel();
	associationModel.setTableName(DBUtility.getTableNameByClassName(className));
	associationModel.setAssociatedTableName(DBUtility.getTableNameByClassName(associatedClassName));
	associationModel.setTableHoldsForeignKey(DBUtility.getTableNameByClassName(classHoldsForeignKey));
	associationModel.setAssociationType(associationType);
	mAssociationModels.add(associationModel);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:LitePalBase.java

示例8: addAssociations

import org.litepal.tablemanager.model.AssociationsModel; //导入依赖的package包/类
/**
 * Analyzing all the association models in the collection. Judge their
 * association types. If it's one2one or many2one associations, add the
 * foreign key column to the associated table. If it's many2many
 * associations, create an intermediate join table.
 * 
 * @param associatedModels
 *            A collection contains all the association models.Use the
 *            association models to get association type and associated
 *            table names.
 * @param db
 *            Instance of SQLiteDatabase.
 * @param force
 *            Drop the table first if it already exists.
 */
private void addAssociations(Collection<AssociationsModel> associatedModels, SQLiteDatabase db,
		boolean force) {
	for (AssociationsModel associationModel : associatedModels) {
		if (Const.Model.MANY_TO_ONE == associationModel.getAssociationType()
				|| Const.Model.ONE_TO_ONE == associationModel.getAssociationType()) {
			addForeignKeyColumn(associationModel.getTableName(),
					associationModel.getAssociatedTableName(),
					associationModel.getTableHoldsForeignKey(), db);
		} else if (Const.Model.MANY_TO_MANY == associationModel.getAssociationType()) {
			createIntermediateTable(associationModel.getTableName(),
					associationModel.getAssociatedTableName(), db, force);
		}
	}
}
 
开发者ID:ownwell,项目名称:zztinews,代码行数:30,代码来源:AssociationCreator.java

示例9: getAllAssociations

import org.litepal.tablemanager.model.AssociationsModel; //导入依赖的package包/类
/**
 * This method is used to get all the association models which in the
 * mapping list of litepal.xml file.
 * 
 * @return Collection of RelationModel for all the mapping classes.
 * 
 * @throws org.litepal.exceptions.DatabaseGenerateException
 */
protected Collection<AssociationsModel> getAllAssociations() {
	if (mAllRelationModels == null || mAllRelationModels.isEmpty()) {
		mAllRelationModels = getAssociations(LitePalAttr.getInstance().getClassNames());
	}
	return mAllRelationModels;
}
 
开发者ID:ownwell,项目名称:zztinews,代码行数:15,代码来源:Generator.java

示例10: isRelationCorrect

import org.litepal.tablemanager.model.AssociationsModel; //导入依赖的package包/类
/**
 * Judge if the tableName1 equals {@link org.litepal.tablemanager.model.AssociationsModel#getTableName()}
 * and tableName2 equals {@link org.litepal.tablemanager.model.AssociationsModel#getAssociatedTableName()}.
 * 
 * @param associationModel
 *            The association model to get table name and associated table
 *            name.
 * @param tableName1
 *            The table name to match table name from association model.
 * @param tableName2
 *            The table name to match associated table name from association
 *            model.
 * @return Return true if the description is true, otherwise return false.
 */
private boolean isRelationCorrect(AssociationsModel associationModel, String tableName1,
		String tableName2) {
	return associationModel.getTableName().equalsIgnoreCase(tableName1)
			&& associationModel.getAssociatedTableName().equalsIgnoreCase(tableName2);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:AssociationUpdater.java


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