Package org.projectforge.continuousdb

Examples of org.projectforge.continuousdb.TableAttribute


      @Override
      public UpdateRunningStatus runUpdate()
      {
        if (dao.doTableAttributesExist(rechnungTable, "konto") == false) {
          dao.addTableAttributes(rechnungTable, new TableAttribute(RechnungDO.class, "konto"));
        }
        if (dao.doTableAttributesExist(userTable, "sshPublicKey") == false) {
          dao.addTableAttributes(userTable, new TableAttribute(PFUserDO.class, "sshPublicKey"));
        }
        final int entriesToMigrate = dao.queryForInt("select count(*) from t_contract where status='IN_PROGRES'");
        if (entriesToMigrate > 0) {
          dao.execute("update t_contract set status='IN_PROGRESS' where status='IN_PROGRES'", true);
        }
        return UpdateRunningStatus.DONE;
      }
    });

    // /////////////////////////////////////////////////////////////////
    // 4.3.1
    // /////////////////////////////////////////////////////////////////
    list.add(new UpdateEntryImpl(CORE_REGION_ID, "4.3.1", "2013-01-29", "Adds t_fibu_projekt.konto") {
      final Table projektTable = new Table(ProjektDO.class);

      @Override
      public UpdatePreCheckStatus runPreCheck()
      {
        return dao.doTableAttributesExist(projektTable, "konto") == true //
            ? UpdatePreCheckStatus.ALREADY_UPDATED
                : UpdatePreCheckStatus.READY_FOR_UPDATE;
      }

      @Override
      public UpdateRunningStatus runUpdate()
      {
        if (dao.doTableAttributesExist(projektTable, "konto") == false) {
          dao.addTableAttributes(projektTable, new TableAttribute(ProjektDO.class, "konto"));
        }
        return UpdateRunningStatus.DONE;
      }
    });

    // /////////////////////////////////////////////////////////////////
    // 4.2
    // /////////////////////////////////////////////////////////////////
    list.add(new UpdateEntryImpl(
        CORE_REGION_ID,
        "4.2",
        "2012-08-09",
        "Adds t_pf_user.authenticationToken|local_user|restricted_user|deactivated|ldap_values, t_group.local_group, t_fibu_rechnung|eingangsrechnung|auftrag(=incoming and outgoing invoice|order).ui_status_as_xml") {
      final Table userTable = new Table(PFUserDO.class);

      final Table groupTable = new Table(GroupDO.class);

      final Table outgoingInvoiceTable = new Table(RechnungDO.class);

      final Table incomingInvoiceTable = new Table(EingangsrechnungDO.class);

      final Table orderTable = new Table(AuftragDO.class);

      @Override
      public UpdatePreCheckStatus runPreCheck()
      {
        return dao.doTableAttributesExist(userTable, "authenticationToken", "localUser", "restrictedUser", "deactivated", "ldapValues") == true //
            && dao.doTableAttributesExist(groupTable, "localGroup") == true // , "nestedGroupsAllowed", "nestedGroupIds") == true //
            && dao.doTableAttributesExist(outgoingInvoiceTable, "uiStatusAsXml") == true //
            && dao.doTableAttributesExist(incomingInvoiceTable, "uiStatusAsXml") == true //
            && dao.doTableAttributesExist(orderTable, "uiStatusAsXml") == true //
            ? UpdatePreCheckStatus.ALREADY_UPDATED : UpdatePreCheckStatus.READY_FOR_UPDATE;
      }

      @Override
      public UpdateRunningStatus runUpdate()
      {
        if (dao.doTableAttributesExist(userTable, "authenticationToken") == false) {
          dao.addTableAttributes(userTable, new TableAttribute(PFUserDO.class, "authenticationToken"));
        }
        if (dao.doTableAttributesExist(userTable, "localUser") == false) {
          dao.addTableAttributes(userTable, new TableAttribute(PFUserDO.class, "localUser").setDefaultValue("false"));
        }
        if (dao.doTableAttributesExist(userTable, "restrictedUser") == false) {
          dao.addTableAttributes(userTable, new TableAttribute(PFUserDO.class, "restrictedUser").setDefaultValue("false"));
        }
        if (dao.doTableAttributesExist(userTable, "deactivated") == false) {
          dao.addTableAttributes(userTable, new TableAttribute(PFUserDO.class, "deactivated").setDefaultValue("false"));
        }
        if (dao.doTableAttributesExist(userTable, "ldapValues") == false) {
          dao.addTableAttributes(userTable, new TableAttribute(PFUserDO.class, "ldapValues"));
        }
        if (dao.doTableAttributesExist(groupTable, "localGroup") == false) {
          dao.addTableAttributes(groupTable, new TableAttribute(GroupDO.class, "localGroup").setDefaultValue("false"));
        }
        // if (dao.doesTableAttributesExist(groupTable, "nestedGroupsAllowed") == false) {
        // dao.addTableAttributes(groupTable, new TableAttribute(GroupDO.class, "nestedGroupsAllowed").setDefaultValue("true"));
        // }
        // if (dao.doesTableAttributesExist(groupTable, "nestedGroupIds") == false) {
        // dao.addTableAttributes(groupTable, new TableAttribute(GroupDO.class, "nestedGroupIds"));
        // }
        if (dao.doTableAttributesExist(outgoingInvoiceTable, "uiStatusAsXml") == false) {
          dao.addTableAttributes(outgoingInvoiceTable, new TableAttribute(RechnungDO.class, "uiStatusAsXml"));
        }
        if (dao.doTableAttributesExist(incomingInvoiceTable, "uiStatusAsXml") == false) {
          dao.addTableAttributes(incomingInvoiceTable, new TableAttribute(EingangsrechnungDO.class, "uiStatusAsXml"));
        }
        if (dao.doTableAttributesExist(orderTable, "uiStatusAsXml") == false) {
          dao.addTableAttributes(orderTable, new TableAttribute(AuftragDO.class, "uiStatusAsXml"));
        }
        return UpdateRunningStatus.DONE;
      }
    });

    // /////////////////////////////////////////////////////////////////
    // 4.1
    // /////////////////////////////////////////////////////////////////
    list.add(new UpdateEntryImpl(CORE_REGION_ID, "4.1", "2012-04-21", "Adds t_pf_user.first_day_of_week and t_pf_user.hr_planning.") {
      final Table userTable = new Table(PFUserDO.class);

      @Override
      public UpdatePreCheckStatus runPreCheck()
      {
        return dao.doTableAttributesExist(userTable, "firstDayOfWeek", "hrPlanning") == true //
            ? UpdatePreCheckStatus.ALREADY_UPDATED
                : UpdatePreCheckStatus.READY_FOR_UPDATE;
      }

      @Override
      public UpdateRunningStatus runUpdate()
      {
        if (dao.doTableAttributesExist(userTable, "firstDayOfWeek") == false) {
          dao.addTableAttributes(userTable, new TableAttribute(PFUserDO.class, "firstDayOfWeek"));
        }
        if (dao.doTableAttributesExist(userTable, "hrPlanning") == false) {
          dao.addTableAttributes(userTable, new TableAttribute(PFUserDO.class, "hrPlanning").setDefaultValue("true"));
        }
        return UpdateRunningStatus.DONE;
      }
    });

    // /////////////////////////////////////////////////////////////////
    // 4.0
    // /////////////////////////////////////////////////////////////////
    list.add(new UpdateEntryImpl(CORE_REGION_ID, "4.0", "2012-04-18",
        "Adds 6th parameter to t_script and payment_type to t_fibu_eingangsrechnung.") {
      final Table scriptTable = new Table(ScriptDO.class);

      final Table eingangsrechnungTable = new Table(EingangsrechnungDO.class);

      @Override
      public UpdatePreCheckStatus runPreCheck()
      {
        return dao.doTableAttributesExist(scriptTable, "parameter6Name", "parameter6Type") == true //
            && dao.doTableAttributesExist(eingangsrechnungTable, "paymentType") == true //
            ? UpdatePreCheckStatus.ALREADY_UPDATED : UpdatePreCheckStatus.READY_FOR_UPDATE;
      }

      @Override
      public UpdateRunningStatus runUpdate()
      {
        if (dao.doTableAttributesExist(scriptTable, "parameter6Name") == false) {
          dao.addTableAttributes(scriptTable, new TableAttribute(ScriptDO.class, "parameter6Name"));
        }
        if (dao.doTableAttributesExist(scriptTable, "parameter6Type") == false) {
          dao.addTableAttributes(scriptTable, new TableAttribute(ScriptDO.class, "parameter6Type"));
        }
        if (dao.doTableAttributesExist(eingangsrechnungTable, "paymentType") == false) {
          dao.addTableAttributes(eingangsrechnungTable, new TableAttribute(EingangsrechnungDO.class, "paymentType"));
        }
        return UpdateRunningStatus.DONE;
      }
    });

    // /////////////////////////////////////////////////////////////////
    // 3.6.2
    // /////////////////////////////////////////////////////////////////
    list.add(new UpdateEntryImpl(
        CORE_REGION_ID,
        "3.6.1.3",
        "2011-12-05",
        "Adds columns t_kunde.konto_id, t_fibu_eingangsrechnung.konto_id, t_konto.status, t_task.protection_of_privacy and t_address.communication_language.") {
      @Override
      public UpdatePreCheckStatus runPreCheck()
      {
        final Table kundeTable = new Table(KundeDO.class);
        final Table eingangsrechnungTable = new Table(EingangsrechnungDO.class);
        final Table kontoTable = new Table(KontoDO.class);
        final Table taskTable = new Table(TaskDO.class);
        final Table addressTable = new Table(AddressDO.class);
        return dao.doTableAttributesExist(kundeTable, "konto") == true //
            && dao.doTableAttributesExist(eingangsrechnungTable, "konto") == true //
            && dao.doTableAttributesExist(kontoTable, "status") == true //
            && dao.doTableAttributesExist(addressTable, "communicationLanguage") == true //
            && dao.doTableAttributesExist(taskTable, "protectionOfPrivacy") //
            ? UpdatePreCheckStatus.ALREADY_UPDATED : UpdatePreCheckStatus.READY_FOR_UPDATE;
      }

      @Override
      public UpdateRunningStatus runUpdate()
      {
        final Table kundeTable = new Table(KundeDO.class);
        if (dao.doTableAttributesExist(kundeTable, "konto") == false) {
          dao.addTableAttributes(kundeTable, new TableAttribute(KundeDO.class, "konto"));
        }
        final Table eingangsrechnungTable = new Table(EingangsrechnungDO.class);
        if (dao.doTableAttributesExist(eingangsrechnungTable, "konto") == false) {
          dao.addTableAttributes(eingangsrechnungTable, new TableAttribute(EingangsrechnungDO.class, "konto"));
        }
        final Table kontoTable = new Table(KontoDO.class);
        if (dao.doTableAttributesExist(kontoTable, "status") == false) {
          dao.addTableAttributes(kontoTable, new TableAttribute(KontoDO.class, "status"));
        }
        final Table taskTable = new Table(TaskDO.class);
        if (dao.doTableAttributesExist(taskTable, "protectionOfPrivacy") == false) {
          dao.addTableAttributes(taskTable, new TableAttribute(TaskDO.class, "protectionOfPrivacy").setDefaultValue("false"));
        }
        final Table addressTable = new Table(AddressDO.class);
        if (dao.doTableAttributesExist(addressTable, "communicationLanguage") == false) {
          dao.addTableAttributes(addressTable, new TableAttribute(AddressDO.class, "communicationLanguage"));
        }
        dao.createMissingIndices();
        return UpdateRunningStatus.DONE;
      }
    });

    // /////////////////////////////////////////////////////////////////
    // 3.5.4
    // /////////////////////////////////////////////////////////////////
    list.add(new UpdateEntryImpl(CORE_REGION_ID, "3.5.4", "2011-02-24",
        "Adds table t_database_update. Adds attribute (excel_)date_format, hour_format_24 to table t_pf_user.") {
      @Override
      public UpdatePreCheckStatus runPreCheck()
      {
        final Table dbUpdateTable = new Table(DatabaseUpdateDO.class);
        final Table userTable = new Table(PFUserDO.class);
        return dao.doExist(dbUpdateTable) == true
            && dao.doTableAttributesExist(userTable, "dateFormat", "excelDateFormat", "timeNotation") == true //
            ? UpdatePreCheckStatus.ALREADY_UPDATED : UpdatePreCheckStatus.READY_FOR_UPDATE;
      }

      @Override
      public UpdateRunningStatus runUpdate()
      {
        final Table dbUpdateTable = new Table(DatabaseUpdateDO.class);
        final Table userTable = new Table(PFUserDO.class);
        dbUpdateTable.addAttributes("updateDate", "regionId", "versionString", "executionResult", "executedBy", "description");
        dao.createTable(dbUpdateTable);
        dao.addTableAttributes(userTable, new TableAttribute(PFUserDO.class, "dateFormat"));
        dao.addTableAttributes(userTable, new TableAttribute(PFUserDO.class, "excelDateFormat"));
        dao.addTableAttributes(userTable, new TableAttribute(PFUserDO.class, "timeNotation"));
        final UserDao userDao = Registry.instance().getDao(UserDao.class);
        dao.createMissingIndices();
        userDao.getUserGroupCache().setExpired();
        return UpdateRunningStatus.DONE;
      }
View Full Code Here


          dao.createSequence("hibernate_sequence", true);
        }
        final SchemaGenerator schemaGenerator = new SchemaGenerator(dao).add(HibernateEntities.CORE_ENTITIES).add(
            HibernateEntities.HISTORY_ENTITIES);
        final Table propertyDeltaTable = schemaGenerator.getTable(PropertyDelta.class);
        final TableAttribute attr = propertyDeltaTable.getAttributeByName("clazz");
        attr.setNullable(false).setType(TableAttributeType.VARCHAR).setLength(31); // Discriminator value is may-be not handled correctly by
        propertyDeltaTable.getAttributeByName("old_value").setLength(20000); // Increase length.
        propertyDeltaTable.getAttributeByName("new_value").setLength(20000); // Increase length.
        // continuous-db.
        final Table historyEntryTable = schemaGenerator.getTable(HistoryEntry.class);
        final TableAttribute typeAttr = historyEntryTable.getAttributeByName("type");
        typeAttr.setType(TableAttributeType.INT);
        schemaGenerator.createSchema();
        dao.createMissingIndices();

        return UpdateRunningStatus.DONE;
      }
View Full Code Here

    assertEquals("T_PLUGIN_MEMO", new Table(MemoDO.class).getName());

    final Table table = new Table(MemoDO.class);
    assertEquals("T_PLUGIN_MEMO", table.getName());
    table.addAttributes("id");
    final TableAttribute attr = table.getAttributes().get(0);
    assertEquals("id", attr.getProperty());
    assertEquals("If id is returned then BeanHelper has returned bridged method of interface.", "pk", attr.getName());
  }
View Full Code Here

  @Test
  public void createTableScript()
  {
    final Table table = new Table("t_test") //
    .addAttribute(new TableAttribute("pk", TableAttributeType.INT).setPrimaryKey(true).setGenerated(true))//
    .addAttribute(new TableAttribute("counter", TableAttributeType.INT)) //
    .addAttribute(new TableAttribute("money", TableAttributeType.DECIMAL, 8, 2).setNullable(false)) //
    .addAttribute(new TableAttribute("address_fk", TableAttributeType.INT).setForeignTable(AddressDO.class));
    final UpdaterConfiguration config = new UpdaterConfiguration();
    config.setDialect(DatabaseDialect.HSQL);
    final MyDatabaseUpdateDao dao = new MyDatabaseUpdateDao(config);
    StringBuffer buf = new StringBuffer();
    dao.buildCreateTableStatement(buf, table);
View Full Code Here

  @Test
  public void createAndDropTable()
  {
    logon(ADMIN);
    final Table table = new Table("t_test") //
    .addAttribute(new TableAttribute("name", TableAttributeType.VARCHAR, 5).setPrimaryKey(true))//
    .addAttribute(new TableAttribute("counter", TableAttributeType.INT)) //
    .addAttribute(new TableAttribute("money", TableAttributeType.DECIMAL, 8, 2).setNullable(false)) //
    .addAttribute(new TableAttribute("address_fk", TableAttributeType.INT).setForeignTable("t_address").setForeignAttribute("pk"));
    final StringBuffer buf = new StringBuffer();
    final MyDatabaseUpdateDao databaseUpdateDao = myDatabaseUpdater.getDatabaseUpdateDao();
    databaseUpdateDao.buildCreateTableStatement(buf, table);
    assertEquals("CREATE TABLE t_test (\n" //
        + "  name VARCHAR(5),\n" //
View Full Code Here

  @Test
  public void buildAddTableColumn()
  {
    final StringBuffer buf = new StringBuffer();
    final MyDatabaseUpdateDao databaseUpdateDao = myDatabaseUpdater.getDatabaseUpdateDao();
    databaseUpdateDao.buildAddTableAttributesStatement(buf, "t_task", new TableAttribute("workpackage_code", TableAttributeType.VARCHAR,
        100, false), new TableAttribute("user_fk", TableAttributeType.INT).setForeignTable("t_user").setForeignAttribute("pk"));
    assertEquals("-- Does already exist: ALTER TABLE t_task ADD COLUMN workpackage_code VARCHAR(100) NOT NULL;\n" //
        + "ALTER TABLE t_task ADD COLUMN user_fk INT;\n"
        + "ALTER TABLE t_task ADD CONSTRAINT t_task_user_fk FOREIGN KEY (user_fk) REFERENCES t_user(pk);\n", buf.toString());
  }
View Full Code Here

  @Test
  public void createAndDropTableColumn()
  {
    final MyDatabaseUpdateDao databaseUpdateDao = myDatabaseUpdater.getDatabaseUpdateDao();
    databaseUpdateDao.addTableAttributes("t_task", new TableAttribute("test1", TableAttributeType.DATE), new TableAttribute("test2",
        TableAttributeType.INT));
    assertTrue(databaseUpdateDao.doesTableAttributeExist("t_task", "test1"));
    assertTrue(databaseUpdateDao.doesTableAttributeExist("t_task", "test2"));
    databaseUpdateDao.dropTableAttribute("t_task", "test1");
    assertFalse(databaseUpdateDao.doesTableAttributeExist("t_task", "test1"));
View Full Code Here

TOP

Related Classes of org.projectforge.continuousdb.TableAttribute

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.