當前位置: 首頁>>代碼示例>>Java>>正文


Java Schema類代碼示例

本文整理匯總了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);
    }
 
開發者ID:MobileDev418,項目名稱:AndroidBackendlessChat,代碼行數:22,代碼來源:Generator.java

示例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;
}
 
開發者ID:MobileDev418,項目名稱:AndroidBackendlessChat,代碼行數:24,代碼來源:Generator.java

示例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;
}
 
開發者ID:MobileDev418,項目名稱:AndroidBackendlessChat,代碼行數:23,代碼來源:Generator.java

示例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");

    }
 
開發者ID:lpy19930103,項目名稱:AndroidPedometer,代碼行數:25,代碼來源:generatePedometerDataBase.java

示例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");
}
 
開發者ID:lpy19930103,項目名稱:MinimalismJotter,代碼行數:23,代碼來源:NoteDaoGenerator.java

示例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);
}
 
開發者ID:ccfish86,項目名稱:sctalk,代碼行數:18,代碼來源:GreenDaoGenerator.java

示例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);
}
 
開發者ID:ccfish86,項目名稱:sctalk,代碼行數:23,代碼來源:GreenDaoGenerator.java

示例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);
}
 
開發者ID:ccfish86,項目名稱:sctalk,代碼行數:23,代碼來源:GreenDaoGenerator.java

示例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;
}
 
開發者ID:ukevgen,項目名稱:BizareChat,代碼行數:18,代碼來源:InitDao.java

示例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;
}
 
開發者ID:ukevgen,項目名稱:BizareChat,代碼行數:18,代碼來源:InitDao.java

示例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;
}
 
開發者ID:ukevgen,項目名稱:BizareChat,代碼行數:22,代碼來源:InitDao.java

示例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);
}
 
開發者ID:DroidKOF,項目名稱:pineapple,代碼行數:21,代碼來源:PineappleGenerator.java

示例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/");
    }
 
開發者ID:Thereisnospon,項目名稱:BlogReader,代碼行數:21,代碼來源:DataDaoGenerator.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");
}
 
開發者ID:Thereisnospon,項目名稱:BlogReader,代碼行數:19,代碼來源:DataDaoGenerator.java

示例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();
    }
 
開發者ID:vinaysshenoy,項目名稱:poirot,代碼行數:24,代碼來源:Migrations.java


注:本文中的de.greenrobot.daogenerator.Schema類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。