本文整理汇总了Java中de.greenrobot.daogenerator.Schema类的典型用法代码示例。如果您正苦于以下问题:Java Schema类的具体用法?Java Schema怎么用?Java Schema使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Schema类属于de.greenrobot.daogenerator包,在下文中一共展示了Schema类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import de.greenrobot.daogenerator.Schema; //导入依赖的package包/类
public static void main(String args[]) throws Exception{
// System.out.print("Generating... " + args[0].toString());
Schema schema = new Schema(54,"com.braunster.chatsdk.dao");
schema.enableKeepSectionsByDefault();
addUser(schema);
addMessages(schema);
addThread(schema);
addLinkedAccounts(schema);
addContactLink(schema);
addUserThreadLink(schema);
addFollower(schema);
setBidirectionalRelationships();
// setImplementation();
setSuperClass();
new DaoGenerator().generateAll(schema, outputDir);
}
示例2: addThread
import de.greenrobot.daogenerator.Schema; //导入依赖的package包/类
private static Property addThread(Schema schema) {
Property threadId;
thread = schema.addEntity(EntityProperties.BThread);
thread.addIdProperty();
threadId = thread.addStringProperty(EntityProperties.EntityID).getProperty();
thread.addDateProperty(EntityProperties.CreationDate);
thread.addBooleanProperty(EntityProperties.HasUnreadMessaged);
thread.addBooleanProperty(EntityProperties.BDeleted);
thread.addStringProperty(EntityProperties.Name);
thread.addDateProperty(EntityProperties.LastMessageAdded);
thread.addIntProperty(EntityProperties.Type);
thread.addStringProperty(EntityProperties.CreatorEntityID);
thread.addStringProperty(EntityProperties.BThreadImageUrl);
thread.addStringProperty(EntityProperties.RootKey).columnName(EntityProperties.C_RootKey);
thread.addStringProperty(EntityProperties.ApiKey).columnName(EntityProperties.C_ApiKey);
Property threadPropCreator = thread.addLongProperty(EntityProperties.CreatorID).getProperty();
ToOne threadToOneCreator = thread.addToOne(user, threadPropCreator);
threadToOneCreator.setName(EntityProperties.Creator);
return threadId;
}
示例3: addMessages
import de.greenrobot.daogenerator.Schema; //导入依赖的package包/类
private static Property addMessages(Schema schema){
Property messageId;
message = schema.addEntity(EntityProperties.BMessage);
message.addIdProperty();
messageId = message.addStringProperty(EntityProperties.EntityID).getProperty();
message.addDateProperty(EntityProperties.Date);
message.addBooleanProperty(EntityProperties.isRead);
message.addStringProperty(EntityProperties.Resource);
message.addStringProperty(EntityProperties.ResourcePath);
message.addStringProperty(EntityProperties.Text);
message.addStringProperty(EntityProperties.ImageDimensions);
message.addIntProperty(EntityProperties.Type);
message.addIntProperty(EntityProperties.Status);
message.addIntProperty(EntityProperties.Delivered);
// The sender ID
Property messagePropSender = message.addLongProperty("Sender").getProperty();
ToOne messageToOneSender = message.addToOne(user, messagePropSender);
messageToOneSender.setName("BUserSender");
return messageId;
}
示例4: addPedometer
import de.greenrobot.daogenerator.Schema; //导入依赖的package包/类
private static void addPedometer(Schema schema) {
PedometerCard = schema.addEntity("PedometerEntity");
PedometerCard.setTableName("PedometerLog");
//默认的id自主增加
PedometerCard.addIdProperty().autoincrement();
//日期,并且是唯一的
// PedometerCard.addStringProperty("date").notNull().unique();
PedometerCard.addStringProperty("date").notNull();
//每日步数
PedometerCard.addIntProperty("dailyStep");
// 步行的距离
// PedometerCard.addDoubleProperty("distanceInMeters");
//开机后总步数
PedometerCard.addIntProperty("totalSteps");
PedometerCard.addIntProperty("tagStep");
PedometerCard.addIntProperty("lastSystemSteps");
//是否重启手机重置,0重置,1未重置
PedometerCard.addBooleanProperty("reStart");
//打卡
PedometerCard.addBooleanProperty("punchCard");
}
示例5: addNote
import de.greenrobot.daogenerator.Schema; //导入依赖的package包/类
/**
* @param schema
*/
private static void addNote(Schema schema) {
Entity note = schema.addEntity("Note");
note.addIdProperty();
note.addIntProperty("note_id");//笔记编号
note.addStringProperty("guid");//用户ID
note.addIntProperty("status");//状态
note.addStringProperty("tag");//类型
note.addStringProperty("label");//标题
note.addStringProperty("content");//内容
note.addStringProperty("imagePath");//图片目录
note.addStringProperty("voicePath");//声音目录
note.addLongProperty("createTime");//创建时间
note.addLongProperty("lastOprTime");//最后修改时间
Entity tag = schema.addEntity("Tag");//标签类型
tag .addIdProperty();
tag.addStringProperty("tag");
tag.addIntProperty("size");
}
示例6: addDepartment
import de.greenrobot.daogenerator.Schema; //导入依赖的package包/类
private static void addDepartment(Schema schema){
Entity department = schema.addEntity("DepartmentEntity");
department.setTableName("Department");
department.setClassNameDao("DepartmentDao");
department.setJavaPackage(entityPath);
department.addIdProperty().autoincrement();
department.addIntProperty("departId").unique().notNull().index();
department.addStringProperty("departName").unique().notNull().index();
department.addIntProperty("priority").notNull();
department.addIntProperty("status").notNull();
department.addIntProperty("created").notNull();
department.addIntProperty("updated").notNull();
department.setHasKeepSections(true);
}
示例7: addGroupInfo
import de.greenrobot.daogenerator.Schema; //导入依赖的package包/类
private static void addGroupInfo(Schema schema) {
Entity groupInfo = schema.addEntity("GroupEntity");
groupInfo.setTableName("GroupInfo");
groupInfo.setClassNameDao("GroupDao");
groupInfo.setJavaPackage(entityPath);
groupInfo.addIdProperty().autoincrement();
groupInfo.addIntProperty("peerId").unique().notNull();
groupInfo.addIntProperty("groupType").notNull();
groupInfo.addStringProperty("mainName").notNull();
groupInfo.addStringProperty("avatar").notNull();
groupInfo.addIntProperty("creatorId").notNull();
groupInfo.addIntProperty("userCnt").notNull();
groupInfo.addStringProperty("userList").notNull();
groupInfo.addIntProperty("version").notNull();
groupInfo.addIntProperty("status").notNull();
groupInfo.addIntProperty("created").notNull();
groupInfo.addIntProperty("updated").notNull();
groupInfo.setHasKeepSections(true);
}
示例8: addSessionInfo
import de.greenrobot.daogenerator.Schema; //导入依赖的package包/类
private static void addSessionInfo(Schema schema){
Entity sessionInfo = schema.addEntity("SessionEntity");
sessionInfo.setTableName("Session");
sessionInfo.setClassNameDao("SessionDao");
sessionInfo.setJavaPackage(entityPath);
//point to userId/groupId need sessionType 区分
sessionInfo.addIdProperty().autoincrement();
sessionInfo.addStringProperty("sessionKey").unique().notNull(); //.unique()
sessionInfo.addIntProperty("peerId").notNull();
sessionInfo.addIntProperty("peerType").notNull();
sessionInfo.addIntProperty("latestMsgType").notNull();
sessionInfo.addIntProperty("latestMsgId").notNull();
sessionInfo.addStringProperty("latestMsgData").notNull();
sessionInfo.addIntProperty("talkId").notNull();
sessionInfo.addIntProperty("created").notNull();
sessionInfo.addIntProperty("updated").notNull();
sessionInfo.setHasKeepSections(true);
}
示例9: addDialog
import de.greenrobot.daogenerator.Schema; //导入依赖的package包/类
private static Entity addDialog(Schema schema){
Entity dialog = schema.addEntity("Dialog");
dialog.addIdProperty().primaryKey().autoincrement();
dialog.addStringProperty("dialog_id");
dialog.addStringProperty("created_at");
dialog.addStringProperty("updated_at");
dialog.addStringProperty("last_message");
dialog.addLongProperty("last_message_date_sent");
dialog.addIntProperty("last_message_user_id");
dialog.addStringProperty("name");
dialog.addStringProperty("photo");
dialog.addStringProperty("occupants_ids");
dialog.addIntProperty("type");
dialog.addIntProperty("unread_messages_count");
dialog.addStringProperty("xmpp_room_jid");
return dialog;
}
示例10: addMessage
import de.greenrobot.daogenerator.Schema; //导入依赖的package包/类
private static Entity addMessage(Schema schema){
Entity message = schema.addEntity("Message");
message.addIdProperty().primaryKey().autoincrement();
message.addStringProperty("message_id");
message.addStringProperty("created_at");
message.addStringProperty("updated_at");
message.addStringProperty("attachments");
message.addStringProperty("read_ids");
message.addStringProperty("delivered_ids");
message.addStringProperty("chat_dialog_id");
message.addLongProperty("date_sent");
message.addStringProperty("message");
message.addStringProperty("recipient_id");
message.addIntProperty("sender_id");
message.addIntProperty("read");
return message;
}
示例11: addUser
import de.greenrobot.daogenerator.Schema; //导入依赖的package包/类
private static Entity addUser(Schema schema){
Entity user = schema.addEntity("User");
user.addIdProperty().primaryKey().autoincrement();
user.addIntProperty("user_id");
user.addStringProperty("full_name");
user.addStringProperty("email");
user.addStringProperty("login");
user.addStringProperty("phone");
user.addStringProperty("website");
user.addStringProperty("created_at");
user.addStringProperty("updated_at");
user.addStringProperty("last_request_at");
user.addStringProperty("external_user_id");
user.addLongProperty("facebook_id");
user.addStringProperty("twitter_id");
user.addIntProperty("twitter_digits_id");
user.addIntProperty("blob_id");
user.addStringProperty("custom_data");
user.addStringProperty("user_tags");
return user;
}
示例12: addCustomerOrder
import de.greenrobot.daogenerator.Schema; //导入依赖的package包/类
/**
* @author:keivn
* @param schema
*/
private static void addCustomerOrder(Schema schema) {
Entity customer = schema.addEntity("Customer");
customer.addIdProperty();
customer.addStringProperty("name").notNull();
Entity order = schema.addEntity("Order");
order.setTableName("ORDERS"); // "ORDER" is a reserved keyword
order.addIdProperty();
Property orderDate = order.addDateProperty("date").getProperty();
Property customerId = order.addLongProperty("customerId").notNull().getProperty();
order.addToOne(customer, customerId);
ToMany customerToOrders = customer.addToMany(order, customerId);
customerToOrders.setName("orders");
customerToOrders.orderAsc(orderDate);
}
示例13: main
import de.greenrobot.daogenerator.Schema; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
// 正如你所见的,你创建了一个用于添加实体(Entity)的模式(Schema)对象。
// 两个参数分别代表:数据库版本号与自动生成代码的包路径。
Schema schema = new Schema(2, "thereisnospon.com.blogreader.database");
// 当然,如果你愿意,你也可以分别指定生成的 Bean 与 DAO 类所在的目录,只要如下所示:
// Schema schema = new Schema(1, "me.itangqi.bean");
// schema.setDefaultJavaPackageDao("me.itangqi.dao");
// 模式(Schema)同时也拥有两个默认的 flags,分别用来标示 entity 是否是 activie 以及是否使用 keep sections。
// schema2.enableActiveEntitiesByDefault();
// schema2.enableKeepSectionsByDefault();
// 一旦你拥有了一个 Schema 对象后,你便可以使用它添加实体(Entities)了。
addHtmlCache(schema);
addArticleType(schema);
// 最后我们将使用 DAOGenerator 类的 generateAll() 方法自动生成代码,此处你需要根据自己的情况更改输出目录(既之前创建的 java-gen)。
// 其实,输出目录的路径可以在 build.gradle 中设置,有兴趣的朋友可以自行搜索,这里就不再详解。
new DaoGenerator().generateAll(schema, "./app/src/main/java/");
}
示例14: addNote
import de.greenrobot.daogenerator.Schema; //导入依赖的package包/类
/**
* @param schema
*/
private static void addNote(Schema schema) {
// 一个实体(类)就关联到数据库中的一张表,此处表名为「Note」(既类名)
Entity note = schema.addEntity("Note");
// 你也可以重新给表命名
// note.setTableName("NODE");
// greenDAO 会自动根据实体类的属性值来创建表字段,并赋予默认值
// 接下来你便可以设置表中的字段:
note.addIdProperty();
note.addStringProperty("text").notNull();
// 与在 Java 中使用驼峰命名法不同,默认数据库中的命名是使用大写和下划线来分割单词的。
// For example, a property called “creationDate” will become a database column “CREATION_DATE”.
note.addStringProperty("comment");
note.addDateProperty("date");
}
示例15: createApplyMethodSpec
import de.greenrobot.daogenerator.Schema; //导入依赖的package包/类
private MethodSpec createApplyMethodSpec(Schema from, Schema to) {
final MethodSpec.Builder applyMigrationSpecBuilder = MethodSpec.methodBuilder("applyMigration")
.addAnnotation(Override.class)
.addModifiers(Modifier.PUBLIC)
.returns(int.class)
.addParameters(Arrays.asList(mDbParameterSpec, mCurrentVersionParameterSpec))
.addStatement("prepareMigration($L,$L)", mDbParameterSpec.name, mCurrentVersionParameterSpec.name);
//Order of these statements is important
handleAddedEntities(from, to, applyMigrationSpecBuilder);
handleRenamedEntities(from, to, applyMigrationSpecBuilder);
handleRemovedEntities(from, to, applyMigrationSpecBuilder);
handleAddedColumns(from, to, applyMigrationSpecBuilder);
handleAddedIndexes(from, to, applyMigrationSpecBuilder);
handleRemovedIndexes(from, to, applyMigrationSpecBuilder);
applyMigrationSpecBuilder.addStatement("return $L()", "getMigratedVersion");
return applyMigrationSpecBuilder
.build();
}