Package org.activiti.engine.management

Examples of org.activiti.engine.management.TableMetaData


    assertEquals(new Long(0), tableCount.get("ACT_RU_TASK"));
    assertEquals(new Long(0), tableCount.get("ACT_RU_IDENTITYLINK"));
  }

  public void testGetTableMetaData() {
    TableMetaData tableMetaData = managementService.getTableMetaData("ACT_RU_TASK");
    assertEquals(tableMetaData.getColumnNames().size(), tableMetaData.getColumnTypes().size());
    assertEquals(15, tableMetaData.getColumnNames().size());

    int assigneeIndex = tableMetaData.getColumnNames().indexOf("ASSIGNEE_");
    int createTimeIndex = tableMetaData.getColumnNames().indexOf("CREATE_TIME_");

    assertTrue(assigneeIndex >= 0);
    assertTrue(createTimeIndex >= 0);
   
    assertOneOf(new String [] {"VARCHAR", "NVARCHAR2", "nvarchar"}, tableMetaData.getColumnTypes().get(assigneeIndex));
    assertOneOf(new String [] {"TIMESTAMP", "TIMESTAMP(6)", "datetime"}, tableMetaData.getColumnTypes().get(createTimeIndex));
  }
View Full Code Here


  }

  @Test
  public void testGetTableMetaData() {
    ManagementService managementService = activitiRule.getManagementService();
    TableMetaData tableMetaData = managementService.getTableMetaData("ACT_RU_TASK");
    assertEquals(tableMetaData.getColumnNames().size(), tableMetaData.getColumnTypes().size());
    assertEquals(15, tableMetaData.getColumnNames().size());

    int assigneeIndex = tableMetaData.getColumnNames().indexOf("ASSIGNEE_");
    int createTimeIndex = tableMetaData.getColumnNames().indexOf("CREATE_TIME_");

    assertTrue(assigneeIndex >= 0);
    assertTrue(createTimeIndex >= 0);
   
    assertOneOf(new String [] {"VARCHAR", "NVARCHAR2", "nvarchar"}, tableMetaData.getColumnTypes().get(assigneeIndex));
    assertOneOf(new String [] {"TIMESTAMP", "TIMESTAMP(6)", "datetime"}, tableMetaData.getColumnTypes().get(createTimeIndex));
  }
View Full Code Here

      order = "asc";
    }
    String sort = getQuery().getValues("sort");

    if (sort == null) {
      TableMetaData tmd = ActivitiUtil.getManagementService().getTableMetaData(tableName);
      List<String> columnNames = tmd.getColumnNames();
      if (columnNames.size() > 0) {
        sort = columnNames.get(0);
      }
      else {
        sort = null;
View Full Code Here

* @author Joram Barrez
*/
public class ManagementServiceTest extends PluggableActivitiTestCase {

  public void testGetMetaDataForUnexistingTable() {
    TableMetaData metaData = managementService.getTableMetaData("unexistingtable");
    assertNull(metaData);
  }
View Full Code Here

  @Autowired
  protected ManagementService managementService;
 
  @RequestMapping(value="/management/tables/{tableName}/columns", method = RequestMethod.GET, produces = "application/json")
  public TableMetaData getTableMetaData(@PathVariable String tableName) {
    TableMetaData response = managementService.getTableMetaData(tableName);
  
    if (response == null) {
      throw new ActivitiObjectNotFoundException("Could not find a table with name '" + tableName + "'.", String.class);
    }
    return response;
View Full Code Here

  public void testGetTableMetaData() {
   
    String tablePrefix = processEngineConfiguration.getDatabaseTablePrefix();
   
    TableMetaData tableMetaData = managementService.getTableMetaData(tablePrefix+"ACT_RU_TASK");
    assertEquals(tableMetaData.getColumnNames().size(), tableMetaData.getColumnTypes().size());
    assertEquals(19, tableMetaData.getColumnNames().size());

    int assigneeIndex = tableMetaData.getColumnNames().indexOf("ASSIGNEE_");
    int createTimeIndex = tableMetaData.getColumnNames().indexOf("CREATE_TIME_");

    assertTrue(assigneeIndex >= 0);
    assertTrue(createTimeIndex >= 0);
   
    assertOneOf(new String [] {"VARCHAR", "NVARCHAR2", "nvarchar", "NVARCHAR"}, tableMetaData.getColumnTypes().get(assigneeIndex));
    assertOneOf(new String [] {"TIMESTAMP", "TIMESTAMP(6)", "datetime", "DATETIME"}, tableMetaData.getColumnTypes().get(createTimeIndex));
  }
View Full Code Here

   * GET management/tables/{tableName}/columns
   */
  public void testGetTableColumns() throws Exception {
    String tableName = managementService.getTableCount().keySet().iterator().next();
   
    TableMetaData metaData = managementService.getTableMetaData(tableName);

    CloseableHttpResponse response = executeRequest(new HttpGet(SERVER_URL_PREFIX +
        RestUrls.createRelativeResourceUrl(RestUrls.URL_TABLE_COLUMNS, tableName)), HttpStatus.SC_OK);
   
    // Check table
    JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
    closeResponse(response);
    assertNotNull(responseNode);
    assertEquals(tableName, responseNode.get("tableName").textValue());
   
    ArrayNode names = (ArrayNode) responseNode.get("columnNames");
    ArrayNode types = (ArrayNode) responseNode.get("columnTypes");
    assertNotNull(names);
    assertNotNull(types);
   
    assertEquals(metaData.getColumnNames().size(), names.size());
    assertEquals(metaData.getColumnTypes().size(), types.size());
   
    for(int i=0; i<names.size(); i++) {
      assertEquals(names.get(i).textValue(), metaData.getColumnNames().get(i));
      assertEquals(types.get(i).textValue(), metaData.getColumnTypes().get(i));
    }
  }
View Full Code Here

      return tableName;
    }
  }

  public TableMetaData getTableMetaData(String tableName) {
    TableMetaData result = new TableMetaData();
    try {
      result.setTableName(tableName);
      DatabaseMetaData metaData = getDbSqlSession()
        .getSqlSession()
        .getConnection()
        .getMetaData();

      if ("postgres".equals(getDbSqlSession().getDbSqlSessionFactory().getDatabaseType())) {
        tableName = tableName.toLowerCase();
      }

      ResultSet resultSet = metaData.getColumns(null, null, tableName, null);
      while(resultSet.next()) {
        String name = resultSet.getString("COLUMN_NAME").toUpperCase();
        String type = resultSet.getString("TYPE_NAME").toUpperCase();
        result.addColumnMetaData(name, type);
      }
     
    } catch (SQLException e) {
      throw new ActivitiException("Could not retrieve database metadata: " + e.getMessage());
    }

    if(result.getColumnNames().isEmpty()) {
      // According to API, when a table doesn't exist, null should be returned
      result = null;
    }
    return result;
  }
View Full Code Here

      data.setHeight(100, UNITS_PERCENTAGE);
      data.addStyleName(ExplorerLayout.STYLE_DATABASE_TABLE);
      setDetailExpandRatio(data, 1.0f);
     
      // Create column headers
      TableMetaData metaData = managementService.getTableMetaData(tableName);
      for (String columnName : metaData.getColumnNames()) {
        data.addContainerProperty(columnName, String.class, null);
      }
     
    } else {
      Label noDataLabel = new Label(i18nManager.getMessage(Messages.DATABASE_NO_ROWS));
View Full Code Here

      data.setHeight(100, UNITS_PERCENTAGE);
      data.addStyleName(ExplorerLayout.STYLE_DATABASE_TABLE);
      setDetailExpandRatio(data, 1.0f);
     
      // Create column headers
      TableMetaData metaData = managementService.getTableMetaData(tableName);
      for (String columnName : metaData.getColumnNames()) {
        data.addContainerProperty(columnName, String.class, null);
      }
     
    } else {
      Label noDataLabel = new Label(i18nManager.getMessage(Messages.DATABASE_NO_ROWS));
View Full Code Here

TOP

Related Classes of org.activiti.engine.management.TableMetaData

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.