Java Code Examples for org.springframework.jdbc.support.rowset.SqlRowSet

The following are top voted examples for showing how to use org.springframework.jdbc.support.rowset.SqlRowSet. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: keti   File: V2_0_1__InitializeIdentityZones.java   Source Code and License 9 votes vote down vote up
private void removeDuplicateRows(final JdbcTemplate jdbcTemplate, final Long zone) {
    final List<SubjectEntity> subjects = jdbcTemplate
            .query("SELECT DISTINCT subject_identifier, attributes FROM subject", new SubjectRowMapper());
    jdbcTemplate.update("DELETE FROM subject *");
    for (SubjectEntity s : subjects) {
        jdbcTemplate.update("INSERT INTO subject (subject_identifier, attributes, "
                        + " authorization_zone_id) VALUES (?,?,?)", s.getSubjectIdentifier(), s
                        .getAttributesAsJson(),
                zone);
    }
    final List<ResourceEntity> resources = jdbcTemplate
            .query("SELECT DISTINCT resource_identifier, attributes FROM resource", new ResourceRowMapper());
    jdbcTemplate.update("DELETE FROM resource *");
    for (ResourceEntity r : resources) {
        jdbcTemplate.update("INSERT INTO resource (resource_identifier, attributes, "
                        + " authorization_zone_id) VALUES (?,?,?)", r.getResourceIdentifier(), r
                        .getAttributesAsJson(),
                zone);
    }

    final List<PolicySetEntity> policysets = jdbcTemplate
            .query("SELECT DISTINCT policy_set_id, policy_set_json FROM policy_set", new PolicySetRowMapper());
    jdbcTemplate.update("DELETE FROM policy_set *");
    for (PolicySetEntity ps : policysets) {
        SqlRowSet row = jdbcTemplate
                .queryForRowSet("SELECT * FROM policy_set WHERE policy_set_id =?", ps.getPolicySetID());
        if (row.next()) {
            jdbcTemplate.update("UPDATE policy_set SET policy_set_json = ? WHERE policy_set_id = ?",
                    ps.getPolicySetJson(), ps.getPolicySetID());
        } else {
            jdbcTemplate.update("INSERT INTO policy_set (policy_set_id, policy_set_json, "
                    + " authorization_zone_id) VALUES (?,?,?)", ps.getPolicySetID(), ps.getPolicySetJson(), zone);
        }
    }
}
 
Example 2
Project: stats-alfresco-on-database   File: LocalDaoImpl.java   Source Code and License 7 votes vote down vote up
@Override
@Transactional
public List<Long> selectparentFolders(List<Long> nodesid) throws SaodException {
	if (nodesid == null || nodesid.size() == 0) {
		return Collections.emptyList();
	}

	NamedParameterJdbcTemplate jdbcNamesTpl = new NamedParameterJdbcTemplate(this.jdbcTemplate);

	MapSqlParameterSource parameters = new MapSqlParameterSource();
	parameters.addValue("ids", nodesid);

	String query = sqlQueries.getQuery("select_parents_folders.sql");
	final SqlRowSet queryForRowSet = jdbcNamesTpl.queryForRowSet(query, parameters);

	final List<Long> ids = new ArrayList<>();
	while (queryForRowSet.next()) {
		ids.add(queryForRowSet.getLong(1));
	}

	return ids;
}
 
Example 3
Project: OperatieBRP   File: AfnemerindicatieBatchStrategy.java   Source Code and License 6 votes vote down vote up
@Override
public void dumpAfnemerindicatieTabelNaarFile(final File outputFile) {
    LOGGER.info("Genereer afnemerindicatie rijen naar {}", outputFile.getAbsolutePath());
    try (FileOutputStream fos = new FileOutputStream(outputFile)) {
        final SqlRowSet sqlRowSet = new JdbcTemplate(masterDataSource).queryForRowSet("select * from autaut.persafnemerindicatie where levsautorisatie "
                + "IN (select id from autaut.levsautorisatie where dateinde is null)");
        while (sqlRowSet.next()) {
            IOUtils.write(String.format("%s,%s,%s,%s,%s,%s,%s%n",
                    sqlRowSet.getString(INDEX_ID),
                    sqlRowSet.getString(INDEX_PERS),
                    sqlRowSet.getString(INDEX_AFNEMER),
                    sqlRowSet.getString(INDEX_LEVSAUTORISATIE),
                    StringUtils.defaultIfEmpty(sqlRowSet.getString(INDEX_DATAANVANGMATERIELEPERIODE), AfnemerindicatieConversie.NULL_VALUE),
                    StringUtils.defaultIfEmpty(sqlRowSet.getString(INDEX_DATEINDEVOLGEN), AfnemerindicatieConversie.NULL_VALUE),
                    sqlRowSet.getString(INDEX_INDAG)
            ), fos, StandardCharsets.UTF_8);
        }
    } catch (IOException e) {
        throw new IllegalStateException(e);
    }
}
 
Example 4
Project: stats-alfresco-on-database   File: LocalDaoImpl.java   Source Code and License 6 votes vote down vote up
@Override
@Transactional
public PrintNode loadRow(Long nodeid) throws SaodException {
	String query = sqlQueries.getQuery("select_row_node_id.sql");
	final SqlRowSet queryForRowSet = this.jdbcTemplate.queryForRowSet(query, nodeid);

	while (queryForRowSet.next()) {
		PrintNode node = new PrintNode(nodeid);
		node.setParent(queryForRowSet.getLong(2));
		node.setLocalSize(queryForRowSet.getLong(3));
		node.setDirSize(queryForRowSet.getLong(4));
		return node;
	}

	return null;
}
 
Example 5
Project: stats-alfresco-on-database   File: AlfrescoDaoImpl.java   Source Code and License 6 votes vote down vote up
@Override
@Transactional
public Map<Long, Long> selectParentNodeId(List<Long> child_id) throws SaodException {
	NamedParameterJdbcTemplate jdbcNamesTpl = new NamedParameterJdbcTemplate(this.jdbcTemplate);

	final String query = sqlQueries.getQuery("select_parent_node_id.sql");
	final Map<Long, Long> libelle = new HashMap<>();

	for (int i = 0; i < child_id.size(); i += MAX_NUM_EXP_LIST) {
		MapSqlParameterSource parameters = new MapSqlParameterSource();
		parameters.addValue("ids", child_id.subList(i, Math.min(i + MAX_NUM_EXP_LIST, child_id.size())));

		final SqlRowSet queryForRowSet = jdbcNamesTpl.queryForRowSet(query, parameters);
		while (queryForRowSet.next()) {
			libelle.put(queryForRowSet.getLong(1), queryForRowSet.getLong(2));
		}

	}

	return libelle;
}
 
Example 6
Project: java-samples   File: JdbcInsertUsageWithSequenceTest.java   Source Code and License 6 votes vote down vote up
/**
 * getAllUsers
 */
public List<User> getAllUsers() {
    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
    List<User> userList = new ArrayList<User>();
    SqlRowSet rowset = jdbcTemplate.queryForRowSet("select * from users_auto");

    while (rowset.next()) {
        User user = new User();
        user.setId(rowset.getInt("ID"));
        user.setName(rowset.getString("NAME"));
        user.setMail(rowset.getString("MAIL"));
        userList.add(user);
    }

    return userList;
}
 
Example 7
Project: dhis2-core   File: IdentityPopulator.java   Source Code and License 6 votes vote down vote up
private void updatePasswordLastUpdated()
{
    try
    {
        String timestamp = DateUtils.getLongDateString();

        SqlRowSet resultSet = jdbcTemplate.queryForRowSet( "SELECT * from users WHERE passwordlastupdated IS NULL" );

        while ( resultSet.next() )
        {
            String sql = "UPDATE users SET passwordlastupdated = '" + timestamp + "' WHERE passwordlastupdated IS NULL";
            jdbcTemplate.update( sql );
        }
    }
    catch ( Exception ex ) // Log and continue
    {
        log.error( "Problem updating passwordLastUpdated on table user: " + ex.getMessage() );
    }
}
 
Example 8
Project: dhis2-core   File: JdbcEventAnalyticsManager.java   Source Code and License 6 votes vote down vote up
@Override
public Rectangle getRectangle( EventQueryParams params )
{
    String clusterField = params.getCoordinateField();
    String quotedClusterField = statementBuilder.columnQuote( clusterField );
            
    String sql = "select count(psi) as " + COL_COUNT + ", ST_Extent(" + quotedClusterField + ") as " + COL_EXTENT + " ";
    
    sql += getFromWhereClause( params );

    log.debug( String.format( "Analytics event count and extent SQL: %s", sql ) );
    
    Rectangle rectangle = new Rectangle();
    
    SqlRowSet rowSet = jdbcTemplate.queryForRowSet( sql );
    
    if ( rowSet.next() )
    {
        Object extent = rowSet.getObject( COL_EXTENT );
        
        rectangle.setCount( rowSet.getLong( COL_COUNT ) );
        rectangle.setExtent( extent != null ? String.valueOf( rowSet.getObject( COL_EXTENT ) ) : null );
    }
    
    return rectangle;
}
 
Example 9
Project: dhis2-core   File: ListGrid.java   Source Code and License 6 votes vote down vote up
@Override
public Grid addRows( SqlRowSet rs )
{
    int cols = rs.getMetaData().getColumnCount();

    while ( rs.next() )
    {
        addRow();

        for ( int i = 1; i <= cols; i++ )
        {
            addValue( rs.getObject( i ) );
        }
    }

    return this;
}
 
Example 10
Project: FinanceAnalytics   File: AbstractDbUserMaster.java   Source Code and License 6 votes vote down vote up
/**
 * Convert a name to an object identifier.
 * <p>
 * If an object is renamed, the old name remains as an alias.
 * The separate name resolution handles that case.
 * 
 * @param name  the name, not null
 * @param onDeleted  how to handle deletion
 * @return the object identifier, null if not found
 */
ObjectId lookupName(String name, OnDeleted onDeleted) {
  ArgumentChecker.notNull(name, "name");
  try (Timer.Context context = _lookupNameTimer.time()) {
    final DbMapSqlParameterSource args = createParameterSource()
      .addValue("name_ci", caseInsensitive(name));
    final NamedParameterJdbcOperations namedJdbc = getDbConnector().getJdbcTemplate();
    final String sql = getElSqlBundle().getSql("GetIdByName", args);
    SqlRowSet rowSet = namedJdbc.queryForRowSet(sql, args);
    if (rowSet.next() == false) {
      throw new DataNotFoundException("Name not found: " + name);
    }
    String deleted = rowSet.getString("DELETED");
    if (deleted.equals("Y")) {
      if (onDeleted == OnDeleted.RETURN_NULL) {
        return null;
      } else if (onDeleted == OnDeleted.EXCEPTION) {
        throw new DataNotFoundException("Name not found: " + name);
      }
    }
    return createObjectId(rowSet.getLong("DOC_ID")).getObjectId();
  }
}
 
Example 11
Project: Tank   File: JdbcMessageDAOTest.java   Source Code and License 6 votes vote down vote up
private static void dump(String sql) {
    logger.fine("\n" + sql);
    SqlRowSet rs = dao.getJdbcTemplate().queryForRowSet(sql);
    try {
        SqlRowSetMetaData rsmd = rs.getMetaData();
        int c = rsmd.getColumnCount();
        StringBuffer buff = new StringBuffer();
        for (int i = 1; i <= c; i++) {
            buff.append(rsmd.getColumnLabel(i));
            buff.append(i == c ? "\n" : "\t");
        }
        logger.fine(buff.toString());
        buff.delete(0, buff.length());
        while (rs.next()) {
            for (int i = 1; i <= c; i++) {
                buff.append(rs.getObject(i));
                buff.append(i == c ? "\n" : "\t");
            }
            logger.fine(buff.toString());
            buff.delete(0, buff.length());
        }
        logger.fine("================\n\n");
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 12
Project: spring-jdbctemplate-streams   File: JdbcStream.java   Source Code and License 6 votes vote down vote up
public <T> T streamQuery(String sql, Function<Stream<SqlRow>, ? extends T> streamer, Object... args) {
    return query(sql, resultSet -> {
        final SqlRowSet rowSet = new ResultSetWrappingSqlRowSet(resultSet);
        final SqlRow sqlRow = new SqlRowAdapter(rowSet);

        Supplier<Spliterator<SqlRow>> supplier = () -> Spliterators.spliteratorUnknownSize(new Iterator<SqlRow>() {
            @Override
            public boolean hasNext() {
                return !rowSet.isLast();
            }

            @Override
            public SqlRow next() {
                if (!rowSet.next()) {
                    throw new NoSuchElementException();
                }
                return sqlRow;
            }
        }, Spliterator.IMMUTABLE);
        return streamer.apply(StreamSupport.stream(supplier, Spliterator.IMMUTABLE, false));

    }, args);
}
 
Example 13
Project: spring-jdbctemplate-streams   File: JdbcStream.java   Source Code and License 6 votes vote down vote up
public Stream<SqlRow> stream() throws SQLException {
    final SqlRowSet rowSet = new ResultSetWrappingSqlRowSet(preparedStatement.executeQuery());
    final SqlRow sqlRow = new SqlRowAdapter(rowSet);

    Supplier<Spliterator<SqlRow>> supplier = () -> Spliterators.spliteratorUnknownSize(new Iterator<SqlRow>() {
        @Override
        public boolean hasNext() {
            return !rowSet.isLast();
        }

        @Override
        public SqlRow next() {
            if (!rowSet.next()) {
                throw new NoSuchElementException();
            }
            return sqlRow;
        }
    }, Spliterator.IMMUTABLE);
    return StreamSupport.stream(supplier, Spliterator.IMMUTABLE, false);
}
 
Example 14
Project: jeecms6   File: CmsMysqlDataBackDaoImpl.java   Source Code and License 6 votes vote down vote up
public List<CmsField> listFields(String tablename) {
	String sql = " desc  " + tablename;
	List<CmsField> fields = new ArrayList<CmsField>();
	SqlRowSet set = getJdbcTemplate().queryForRowSet(sql);
	while (set.next()) {
		CmsField field = new CmsField();
		field.setName(set.getString(1));
		field.setFieldType(set.getString(2));
		field.setNullable(set.getString(3));
		field.setFieldProperty(set.getString(4));
		field.setFieldDefault(set.getString(5));
		field.setExtra(set.getString(6));
		fields.add(field);
	}
	return fields;
}
 
Example 15
Project: nakadi   File: EventTypeDbRepositoryTest.java   Source Code and License 6 votes vote down vote up
@Test
public void whenCreateNewEventTypePersistItInTheDatabase() throws Exception {
    final EventType eventType = buildDefaultEventType();

    repository.saveEventType(eventType);

    final SqlRowSet rs =
            template.queryForRowSet("SELECT et_event_type_object FROM zn_data.event_type WHERE et_name=?",
                    eventType.getName());
    rs.next();

    final EventType persisted = TestUtils.OBJECT_MAPPER.readValue(rs.getString(1), EventType.class);

    assertThat(persisted.getCategory(), equalTo(eventType.getCategory()));
    assertThat(persisted.getName(), equalTo(eventType.getName()));
    assertThat(persisted.getSchema().getType(), equalTo(eventType.getSchema().getType()));
    assertThat(persisted.getSchema().getSchema(), equalTo(eventType.getSchema().getSchema()));
}
 
Example 16
Project: nakadi   File: EventTypeDbRepositoryTest.java   Source Code and License 6 votes vote down vote up
@Test
public void whenCreateNewEventTypeAlsoInsertIntoSchemaTable() throws Exception {
    final EventType eventType = buildDefaultEventType();

    repository.saveEventType(eventType);

    final int rows = template.queryForObject(
            "SELECT count(*) FROM zn_data.event_type_schema where ets_event_type_name=?",
            Integer.class, eventType.getName());
    assertThat("Number of rows should increase", rows, equalTo(1));

    final SqlRowSet rs = template.queryForRowSet(
            "SELECT ets_schema_object FROM zn_data.event_type_schema where ets_event_type_name=?",
            eventType.getName());
    rs.next();

    final EventTypeSchema persisted = TestUtils.OBJECT_MAPPER.readValue(rs.getString(1), EventTypeSchema.class);

    assertThat(persisted.getVersion(), equalTo(eventType.getSchema().getVersion()));
    assertThat(persisted.getCreatedAt(), notNullValue());
    assertThat(persisted.getSchema(), equalTo(eventType.getSchema().getSchema()));
    assertThat(persisted.getType(), equalTo(eventType.getSchema().getType()));
}
 
Example 17
Project: AgileAlligators   File: IdentityPopulator.java   Source Code and License 6 votes vote down vote up
private void updatePasswordLastUpdated()
{
    try
    {
        String timestamp = DateUtils.getLongDateString();

        SqlRowSet resultSet = jdbcTemplate.queryForRowSet( "SELECT * from users WHERE passwordlastupdated IS NULL" );

        while ( resultSet.next() )
        {
            String sql = "UPDATE users SET passwordlastupdated = '" + timestamp + "' WHERE passwordlastupdated IS NULL";
            jdbcTemplate.update( sql );
        }
    }
    catch ( Exception ex ) // Log and continue
    {
        log.error( "Problem updating passwordLastUpdated on table user: " + ex.getMessage() );
    }
}
 
Example 18
Project: AgileAlligators   File: IdentityPopulator.java   Source Code and License 6 votes vote down vote up
private void createOrgUnitUuids()
{
    try
    {
        SqlRowSet resultSet = jdbcTemplate.queryForRowSet( "SELECT * from organisationunit WHERE uuid IS NULL" );
        int count = 0;

        while ( resultSet.next() )
        {
            ++count;
            int id = resultSet.getInt( "organisationunitid" );
            String sql = "update organisationunit set uuid = '" + UUID.randomUUID().toString() + "' where organisationunitid = " + id;
            jdbcTemplate.update( sql );
        }

        if ( count > 0 )
        {
            log.info( count + " UUIDs updated on organisationunit" );
        }
    }
    catch ( Exception ex ) // Log and continue
    {
        log.error( "Problem updating organisationunit: ", ex );
    }
}
 
Example 19
Project: AgileAlligators   File: HibernateCaseAggregationConditionStore.java   Source Code and License 6 votes vote down vote up
@Override
public Grid getAggregateValue( String sql, I18nFormat format, I18n i18n )
{
    Grid grid = new ListGrid();

    grid.addHeader( new GridHeader( i18n.getString( "dataelementid" ), true, true ) );
    grid.addHeader( new GridHeader( i18n.getString( "categoryoptioncomboid" ), true, true ) );
    grid.addHeader( new GridHeader( i18n.getString( "periodid" ), true, true ) );
    grid.addHeader( new GridHeader( i18n.getString( "organisationunitid" ), true, true ) );
    grid.addHeader( new GridHeader( i18n.getString( "storedby" ), true, true ) );
    grid.addHeader( new GridHeader( i18n.getString( "dataelementname" ), false, true ) );
    grid.addHeader( new GridHeader( i18n.getString( "categoryoptioncomboname" ), false, true ) );
    grid.addHeader( new GridHeader( i18n.getString( "organisationunitname" ), false, true ) );
    grid.addHeader( new GridHeader( i18n.getString( "value" ), false, true ) );

    SqlRowSet rs = jdbcTemplate.queryForRowSet( sql );
    grid.addRows( rs );

    return grid;
}
 
Example 20
Project: AgileAlligators   File: HibernateCaseAggregationConditionStore.java   Source Code and License 6 votes vote down vote up
@Override
public Grid getAggregateValueDetails( CaseAggregationCondition aggregationCondition, OrganisationUnit orgunit,
    Period period, boolean nonRegistrationProgram, I18nFormat format, I18n i18n )
{
    Grid grid = new ListGrid();
    grid.setTitle( orgunit.getName() + " - " + aggregationCondition.getDisplayName() );
    grid.setSubtitle( format.formatPeriod( period ) );

    String sql = parseExpressionDetailsToSql( aggregationCondition.getAggregationExpression(),
        aggregationCondition.getOperator(), orgunit.getId(), period, nonRegistrationProgram );

    SqlRowSet rs = jdbcTemplate.queryForRowSet( sql );

    for ( String colName : rs.getMetaData().getColumnNames() )
    {
        grid.addHeader( new GridHeader( i18n.getString( colName ), false, true ) );
    }

    addRows( rs, grid );

    return grid;
}
 
Example 21
Project: AgileAlligators   File: JDBCDataBrowserStore.java   Source Code and License 6 votes vote down vote up
private static void setHeaderStructure( Grid grid, SqlRowSet resultSet, List<Integer> headerIds, boolean isZeroAdded )
{
    Integer headerId = null;
    String headerName = null;

    while ( resultSet.next() )
    {
        headerId = resultSet.getInt( 4 );
        headerName = resultSet.getString( 5 );

        GridHeader header = new GridHeader( headerName, headerId + "", String.class.getName(), false, false );

        if ( !headerIds.contains( headerId ) )
        {
            headerIds.add( headerId );
            grid.addHeader( header );

            for ( List<Object> row : grid.getRows() )
            {
                row.add( isZeroAdded ? "0" : "" );
            }
        }
    }
}
 
Example 22
Project: AgileAlligators   File: ListGrid.java   Source Code and License 6 votes vote down vote up
@Override
public Grid addRows( SqlRowSet rs )
{
    int cols = rs.getMetaData().getColumnCount();

    while ( rs.next() )
    {
        addRow();

        for ( int i = 1; i <= cols; i++ )
        {
            addValue( rs.getObject( i ) );
        }
    }
    
    return this;
}
 
Example 23
Project: elpaaso-core   File: CheckVariousRefactoringCommandsIT.java   Source Code and License 6 votes vote down vote up
/**
 * This test verifies a pattern to implement database denormalization
 * Given a database with 3 tables table_1, table_1 and table_3 modeling an inheritance entity_1 > entity_2 > entity_3
 * When schema is denormalized
 * Then table_1 and table_2 data are moved into table_3
 */
@Test
public void testDenormalization() throws SQLException, LiquibaseException {
	// Prepare test data: complete initialization with additional change set
	applyChangeLog("classpath:./test-changesets/denormalization-init-changeset.xml");
	
	// Run test
	applyChangeLog("classpath:./test-changesets/denormalization-migration-changeset.xml");	

	// Assertions
	SqlRowSet results = jdbcTemplate.queryForRowSet("select id, c1, c2, c3 from table_3");
	assertTrue("no data in SqlRowSet results", results.first());
	do {
		int id = results.getInt("id");
		String c1 = results.getString("c1");
		String c2 = results.getString("c2");
		String c3 = results.getString("c3");
		assertEquals("t1v"+id, c1);
		assertEquals("t2v"+id, c2);
		assertEquals("t3v"+id, c3);
	} while(results.next());
	
}
 
Example 24
Project: FoxBPM   File: SelectRoleTest.java   Source Code and License 6 votes vote down vote up
/**
 * 任务分配给一个角色或多个角色
 * <p>1.使用场景:需要将任务分配给一个角色或多个角色</p>
 * <p>2.预置条件:<p>
 *          1.存在角色
 * <p>3.处理过程:首先,启动任务使流程进入分配任务节点上</p>
 * <p>4.测试用例:</p>
 * <p>		1.执行完成后,相应查看资源是否分配给相应角色</p>
 */
@Test
@Deployment(resources = { "org/foxbpm/connector/test/actorconnector/SelectRole/SelectRoleTest_1.bpmn" })
public void testSelectDepartment0() {
	Authentication.setAuthenticatedUserId("admin");
	// 预置角色
	jdbcTemplate.execute("insert into au_roleinfo(roleid,rolename) VALUES ('2001','2001')");
	// 预置用户用户
	jdbcTemplate.execute("insert into au_userInfo(userId,USERNAME) VALUES ('a','管理员Tst')");
	// 设置用户和部门关系
	jdbcTemplate.execute("insert into au_group_relation(guid,userid,groupid,grouptype) VALUES ('10000000000000001','a','2001','role')");
	// 启动流程触发任务分配
	runtimeService.startProcessInstanceByKey("SelectRoleTest_1");
	Task task = (Task) taskService.createTaskQuery().processDefinitionKey("SelectRoleTest_1").taskNotEnd().singleResult();
	// 同时分配给两个人
	String taskId = task.getId();
	SqlRowSet sqlRowSet = jdbcTemplate.queryForRowSet("select * from foxbpm_run_taskidentitylink WHERE TASK_ID = '" + taskId + "'");
	String groupId = null;
	while (sqlRowSet.next()) {
		groupId = sqlRowSet.getString("GROUP_ID");
	}
	assertEquals("2001", groupId);
}
 
Example 25
Project: FoxBPM   File: SelectDeptActorConnectorTest.java   Source Code and License 6 votes vote down vote up
/**
 * 资源共享
 * <p>1.使用场景:将任务分配给某部门(部门可以多个)</p>
 * <p>2.预置条件:<p>
 *          1.发布一条带有任务分配(分配部门)的流程定义
 * <p>3.处理过程:首先,启动任务使流程进入分配任务节点上</p>
 * <p>4.测试用例:</p>
 * <p>		1.执行完成后,相应查看资源分配是否是所以人都能看得到</p>
 * <p>		2.执行完成后,相应查看foxbpm_run_taskidentitylink任务是否分配给部门</p>
 */
@Test
@Deployment(resources = { "org/foxbpm/connector/test/actorconnector/SelectDeptActorConnector/SelectDeptActorConnectorTest_1.bpmn" })
public void testSelectDeptActorConnector() {
	Authentication.setAuthenticatedUserId("admin");
	// 启动流程
	runtimeService.startProcessInstanceByKey("SelectDeptActorConnectorTest_1");
	Task task = taskService.createTaskQuery().processDefinitionKey("SelectDeptActorConnectorTest_1").taskNotEnd().singleResult();
	SqlRowSet sqlRowSet = jdbcTemplate.queryForRowSet("select * from foxbpm_run_taskidentitylink WHERE TASK_ID = '" + task.getId() + "'");
	List<String> userIds = new ArrayList<String>();
	while (sqlRowSet.next()) {
		userIds.add(sqlRowSet.getString("GROUP_ID"));
	}
	if (!userIds.contains("a") || !userIds.contains("b")) {
		throw new FoxBPMConnectorException("选择用户连接器出现异常");
	}
}
 
Example 26
Project: FoxBPM   File: AllUserActorConnectorTest.java   Source Code and License 6 votes vote down vote up
/**
 * 资源共享
 * <p>1.使用场景:将任务共享给所有用户</p>
 * <p>2.预置条件:<p>
 *          1.发布一条带有任务分配(分配所有人)的流程定义
 * <p>3.处理过程:首先,启动任务使流程进入分配任务节点上</p>
 * <p>4.测试用例:</p>
 * <p>		1.执行完成后,相应查看资源分配是否是所以人都能看得到</p>
 * <p>		2.执行完成后,相应查看foxbpm_run_taskidentitylink 记录是否任务的处理者是foxbpm_all_user</p>
 */
@Test
@Deployment(resources = { "org/foxbpm/connector/test/actorconnector/AllUserActorConnector/AllUserActorConnectorTest_1.bpmn" })
public void testAllUserActorConnector() {
	Authentication.setAuthenticatedUserId("admin");
	// 启动流程
	runtimeService.startProcessInstanceByKey("AllUserActorConnectorTest_1");

	Task task = taskService.createTaskQuery().processDefinitionKey("AllUserActorConnectorTest_1").taskNotEnd().singleResult();
	// 同时分配给两个人
	String taskId = task.getId();
	SqlRowSet sqlRowSet = jdbcTemplate.queryForRowSet("select * from foxbpm_run_taskidentitylink WHERE TASK_ID = '" + taskId + "'");

	String userId = null;
	if (sqlRowSet.next()) {
		userId = sqlRowSet.getString("USER_ID");
	}
	assertEquals("foxbpm_all_user", userId);
}
 
Example 27
Project: FoxBPM   File: SelectUserActorConnectorTest.java   Source Code and License 6 votes vote down vote up
/**
 * 任务分配给指定用户可以多个
 * <p>1.使用场景:需要将任务分配指定用户</p>
 * <p>2.预置条件:创建一个含有人工任务并且任务分配给指定用户的流程定义并发布<p>
 * <p>3.处理过程:首先,启动任务使流程进入分配任务节点上</p>
 * <p>4.测试用例:</p>
 * <p>		1.执行完成后,相应查看资源是否分配给指定用户</p>
 */
@Test
@Deployment(resources = { "org/foxbpm/connector/test/actorconnector/SelectUserActorConnector/SelectUserActorConnectorTest_1.bpmn" })
public void testSelectUserActorConnector() {
	Authentication.setAuthenticatedUserId("admin");
	// 启动流程
	runtimeService.startProcessInstanceByKey("SelectUserActorConnectorTest_1");
	Task task = taskService.createTaskQuery().processDefinitionKey("SelectUserActorConnectorTest_1").taskNotEnd().singleResult();
	SqlRowSet sqlRowSet = jdbcTemplate.queryForRowSet("select * from foxbpm_run_taskidentitylink WHERE TASK_ID = '" + task.getId() + "'");
	List<String> userIds = new ArrayList<String>();
	while (sqlRowSet.next()) {
		userIds.add(sqlRowSet.getString("USER_ID"));
	}
	if (!userIds.contains("a") || !userIds.contains("b")) {
		throw new FoxBPMConnectorException("选择用户连接器出现异常");
	}
}
 
Example 28
Project: OLE-INST   File: StatusCodeAndDescriptionForPurapDocumentsDaoJdbc.java   Source Code and License 6 votes vote down vote up
/**
 * @see org.kuali.ole.module.purap.dataaccess.StatusCodeAndDescriptionForPurapDocumentsDao#getRequisitionDocumentStatuses()
 */
public Map<String, String> getRequisitionDocumentStatuses() {
    LOG.debug("getRequisitionDocumentStatuses() started");

    Map<String, String> requistionStatuses = new HashMap<String, String>();

    try {
        SqlRowSet statusesRowSet = getJdbcTemplate().queryForRowSet("SELECT * FROM PUR_REQS_STAT_T ORDER BY REQS_STAT_CD");

        while (statusesRowSet.next()) {
            requistionStatuses.put(statusesRowSet.getString("REQS_STAT_CD"), statusesRowSet.getString("REQS_STAT_DESC"));
        }

        LOG.debug("getRequisitionDocumentStatuses() exited");

        return requistionStatuses;
    } catch (DataAccessException dae) {
        return requistionStatuses;
    }
}
 
Example 29
Project: OLE-INST   File: StatusCodeAndDescriptionForPurapDocumentsDaoJdbc.java   Source Code and License 6 votes vote down vote up
/**
 * @see org.kuali.ole.module.purap.dataaccess.StatusCodeAndDescriptionForPurapDocumentsDao#getPurchaseOrderDocumentStatuses()
 */
public Map<String, String> getPurchaseOrderDocumentStatuses() {
    LOG.debug("getPurchaseOrderDocumentStatuses() started");

    Map<String, String> purchaseOrderStatuses = new HashMap<String, String>();
    try {
        SqlRowSet statusesRowSet = getJdbcTemplate().queryForRowSet("SELECT * FROM PUR_PO_STAT_T ORDER BY PO_STAT_CD");

        while (statusesRowSet.next()) {
            purchaseOrderStatuses.put(statusesRowSet.getString("PO_STAT_CD"), statusesRowSet.getString("PO_STAT_DESC"));
        }

        LOG.debug("getPurchaseOrderDocumentStatuses() exited");

        return purchaseOrderStatuses;
    } catch (DataAccessException dae) {
        return purchaseOrderStatuses;
    }
}
 
Example 30
Project: OLE-INST   File: StatusCodeAndDescriptionForPurapDocumentsDaoJdbc.java   Source Code and License 6 votes vote down vote up
/**
 * @see org.kuali.ole.module.purap.dataaccess.StatusCodeAndDescriptionForPurapDocumentsDao#getPaymentRequestDocumentStatuses()
 */
public Map<String, String> getPaymentRequestDocumentStatuses() {
    LOG.debug("getPaymentRequestDocumentStatuses() started");

    Map<String, String> paymentRequestStatuses = new HashMap<String, String>();

    try {
        SqlRowSet statusesRowSet = getJdbcTemplate().queryForRowSet("SELECT * FROM AP_PMT_RQST_STAT_T ORDER BY PMT_RQST_STAT_CD");

        while (statusesRowSet.next()) {
            paymentRequestStatuses.put(statusesRowSet.getString("PMT_RQST_STAT_CD"), statusesRowSet.getString("PMT_RQST_STAT_DESC"));
        }

        LOG.debug("getPaymentRequestDocumentStatuses() exited");

        return paymentRequestStatuses;
    } catch (DataAccessException dae) {
        return paymentRequestStatuses;
    }
}
 
Example 31
Project: OLE-INST   File: StatusCodeAndDescriptionForPurapDocumentsDaoJdbc.java   Source Code and License 6 votes vote down vote up
/**
 * @see org.kuali.ole.module.purap.dataaccess.StatusCodeAndDescriptionForPurapDocumentsDao#getVendorCreditMemoDocumentStatuses()
 */
public Map<String, String> getVendorCreditMemoDocumentStatuses() {
    LOG.debug("getVendorCreditMemoDocumentStatuses() started");

    Map<String, String> vendorCreditMemoStatuses = new HashMap<String, String>();

    try {
        SqlRowSet statusesRowSet = getJdbcTemplate().queryForRowSet("SELECT * FROM AP_CRDT_MEMO_STAT_T ORDER BY CRDT_MEMO_STAT_CD");

        while (statusesRowSet.next()) {
            vendorCreditMemoStatuses.put(statusesRowSet.getString("CRDT_MEMO_STAT_CD"), statusesRowSet.getString("CRDT_MEMO_STAT_DESC"));
        }

        LOG.debug("getVendorCreditMemoDocumentStatuses() exited");

        return vendorCreditMemoStatuses;
    } catch (DataAccessException dae) {
        return vendorCreditMemoStatuses;
    }
}
 
Example 32
Project: OLE-INST   File: StatusCodeAndDescriptionForPurapDocumentsDaoJdbc.java   Source Code and License 6 votes vote down vote up
/**
 * @see org.kuali.ole.module.purap.dataaccess.StatusCodeAndDescriptionForPurapDocumentsDao#getLineItemReceivingDocumentStatuses()
 */
public Map<String, String> getLineItemReceivingDocumentStatuses() {
    LOG.debug("getLineItemReceivingDocumentStatuses() started");

    Map<String, String> lineItemReceivingStatuses = new HashMap<String, String>();

    try {
        SqlRowSet statusesRowSet = getJdbcTemplate().queryForRowSet("SELECT * FROM PUR_RCVNG_LN_STAT_T ORDER BY RCVNG_LN_STAT_CD");

        while (statusesRowSet.next()) {
            lineItemReceivingStatuses.put(statusesRowSet.getString("RCVNG_LN_STAT_CD"), statusesRowSet.getString("RCVNG_LN_STAT_DESC"));
        }

        LOG.debug("getLineItemReceivingDocumentStatuses() exited");

        return lineItemReceivingStatuses;
    } catch (DataAccessException dae) {
        return lineItemReceivingStatuses;
    }
}
 
Example 33
Project: OLE-INST   File: PurapDocumentsStatusCodeMigrationDaoJdbc.java   Source Code and License 6 votes vote down vote up
/**
 * @see org.kuali.ole.module.purap.dataaccess.PurapDocumentsStatusCodeMigrationDao#getRequisitionDocumentDetails()
 */
public Map<String, String> getRequisitionDocumentDetails() {
    LOG.debug("getRequisitionDocumentDetails() started");

    Map<String, String> requistionDetails = new HashMap<String, String>();

    try {
        SqlRowSet statusesRowSet = getJdbcTemplate().queryForRowSet("SELECT * FROM PUR_REQS_T WHERE REQS_STAT_CD IS NOT NULL");

        while (statusesRowSet.next()) {
            requistionDetails.put(statusesRowSet.getString("FDOC_NBR"), statusesRowSet.getString("REQS_STAT_CD"));
        }

        LOG.debug("getRequisitionDocumentDetails() exited");
        return requistionDetails;

    } catch (DataAccessException dae) {
        return requistionDetails;
    }
}
 
Example 34
Project: OLE-INST   File: PurapDocumentsStatusCodeMigrationDaoJdbc.java   Source Code and License 6 votes vote down vote up
/**
 * @see org.kuali.ole.module.purap.dataaccess.PurapDocumentsStatusCodeMigrationDao#getPurchaseOrderDocumentDetails()
 */
public Map<String, String> getPurchaseOrderDocumentDetails() {
    LOG.debug("getPurchaseOrderDocumentDetails() started");

    Map<String, String> purchaseOrderDetails = new HashMap<String, String>();

    try {
        SqlRowSet statusesRowSet = getJdbcTemplate().queryForRowSet("SELECT * FROM PUR_PO_T WHERE PO_STAT_CD IS NOT NULL");

        while (statusesRowSet.next()) {
            purchaseOrderDetails.put(statusesRowSet.getString("FDOC_NBR"), statusesRowSet.getString("PO_STAT_CD"));
        }

        LOG.debug("getPurchaseOrderDocumentDetails() exited");

        return purchaseOrderDetails;
    } catch (DataAccessException dae) {
        return purchaseOrderDetails;
    }
}
 
Example 35
Project: OLE-INST   File: PurapDocumentsStatusCodeMigrationDaoJdbc.java   Source Code and License 6 votes vote down vote up
/**
 * @see org.kuali.ole.module.purap.dataaccess.PurapDocumentsStatusCodeMigrationDao#getPaymentRequestDocumentDetails()
 */
public Map<String, String> getPaymentRequestDocumentDetails() {
    LOG.debug("getPaymentRequestDocumentDetails() started");

    Map<String, String> paymentRequestDetails = new HashMap<String, String>();

    try {
        SqlRowSet statusesRowSet = getJdbcTemplate().queryForRowSet("SELECT * FROM AP_PMT_RQST_T WHERE PMT_RQST_STAT_CD IS NOT NULL");

        while (statusesRowSet.next()) {
            paymentRequestDetails.put(statusesRowSet.getString("FDOC_NBR"), statusesRowSet.getString("PMT_RQST_STAT_CD"));
        }

        LOG.debug("getPaymentRequestDocumentDetails() exited");

        return paymentRequestDetails;
    } catch (DataAccessException dae) {
        return paymentRequestDetails;
    }
}
 
Example 36
Project: OLE-INST   File: PurapDocumentsStatusCodeMigrationDaoJdbc.java   Source Code and License 6 votes vote down vote up
/**
 * @see org.kuali.ole.module.purap.dataaccess.PurapDocumentsStatusCodeMigrationDao#getVendorCreditMemoDocumentDetails()
 */
public Map<String, String> getVendorCreditMemoDocumentDetails() {
    LOG.debug("getVendorCreditMemoDocumentDetails() started");

    Map<String, String> vendorCreditMemoDetails = new HashMap<String, String>();

    try {
        SqlRowSet statusesRowSet = getJdbcTemplate().queryForRowSet("SELECT * FROM AP_CRDT_MEMO_T WHERE CRDT_MEMO_STAT_CD IS NOT NULL");

        while (statusesRowSet.next()) {
            vendorCreditMemoDetails.put(statusesRowSet.getString("FDOC_NBR"), statusesRowSet.getString("CRDT_MEMO_STAT_CD"));
        }

        LOG.debug("getVendorCreditMemoDocumentDetails() exited");

        return vendorCreditMemoDetails;
    } catch (DataAccessException dae) {
        return vendorCreditMemoDetails;
    }
}
 
Example 37
Project: OLE-INST   File: PurapDocumentsStatusCodeMigrationDaoJdbc.java   Source Code and License 6 votes vote down vote up
/**
 * @see org.kuali.ole.module.purap.dataaccess.PurapDocumentsStatusCodeMigrationDao#getLineItemReceivingDocumentDetails()
 */
public Map<String, String> getLineItemReceivingDocumentDetails() {
    LOG.debug("getLineItemReceivingDocumentDetails() started");

    Map<String, String> lineItemRecvDetails = new HashMap<String, String>();

    try {
        SqlRowSet statusesRowSet = getJdbcTemplate().queryForRowSet("SELECT * FROM PUR_RCVNG_LN_T WHERE RCVNG_LN_STAT_CD IS NOT NULL");

        while (statusesRowSet.next()) {
            lineItemRecvDetails.put(statusesRowSet.getString("FDOC_NBR"), statusesRowSet.getString("RCVNG_LN_STAT_CD"));
        }

        LOG.debug("getLineItemReceivingDocumentDetails() exited");

        return lineItemRecvDetails;
    } catch (DataAccessException dae) {
        return lineItemRecvDetails;
    }
}
 
Example 38
Project: kfs   File: StatusCodeAndDescriptionForPurapDocumentsDaoJdbc.java   Source Code and License 6 votes vote down vote up
/**
 * @see org.kuali.kfs.module.purap.dataaccess.StatusCodeAndDescriptionForPurapDocumentsDao#getRequisitionDocumentStatuses()
 */
public Map<String, String> getRequisitionDocumentStatuses() {
    LOG.debug("getRequisitionDocumentStatuses() started");
    
    Map<String, String> requistionStatuses = new HashMap<String, String>();
    
    try {
        SqlRowSet statusesRowSet = getJdbcTemplate().queryForRowSet("SELECT * FROM PUR_REQS_STAT_T ORDER BY REQS_STAT_CD"); 

        while (statusesRowSet.next()) {
            requistionStatuses.put(statusesRowSet.getString("REQS_STAT_CD"), statusesRowSet.getString("REQS_STAT_DESC"));
        }
        
        LOG.debug("getRequisitionDocumentStatuses() exited");
        
        return requistionStatuses;
    } catch (DataAccessException dae) {
        return requistionStatuses;
    }
}
 
Example 39
Project: kfs   File: StatusCodeAndDescriptionForPurapDocumentsDaoJdbc.java   Source Code and License 6 votes vote down vote up
/**
 * @see org.kuali.kfs.module.purap.dataaccess.StatusCodeAndDescriptionForPurapDocumentsDao#getPurchaseOrderDocumentStatuses()
 */
public Map<String, String> getPurchaseOrderDocumentStatuses() {
    LOG.debug("getPurchaseOrderDocumentStatuses() started");
    
    Map<String, String> purchaseOrderStatuses = new HashMap<String, String>();
    try {
        SqlRowSet statusesRowSet = getJdbcTemplate().queryForRowSet("SELECT * FROM PUR_PO_STAT_T ORDER BY PO_STAT_CD"); 

        while (statusesRowSet.next()) {
            purchaseOrderStatuses.put(statusesRowSet.getString("PO_STAT_CD"), statusesRowSet.getString("PO_STAT_DESC"));
        }
        
        LOG.debug("getPurchaseOrderDocumentStatuses() exited");
        
        return purchaseOrderStatuses;
    } catch (DataAccessException dae) {
        return purchaseOrderStatuses;
    }
}
 
Example 40
Project: kfs   File: StatusCodeAndDescriptionForPurapDocumentsDaoJdbc.java   Source Code and License 6 votes vote down vote up
/**
 * @see org.kuali.kfs.module.purap.dataaccess.StatusCodeAndDescriptionForPurapDocumentsDao#getPaymentRequestDocumentStatuses()
 */
public Map<String, String> getPaymentRequestDocumentStatuses() {
    LOG.debug("getPaymentRequestDocumentStatuses() started");
    
    Map<String, String> paymentRequestStatuses = new HashMap<String, String>();
    
    try {
        SqlRowSet statusesRowSet = getJdbcTemplate().queryForRowSet("SELECT * FROM AP_PMT_RQST_STAT_T ORDER BY PMT_RQST_STAT_CD"); 

        while (statusesRowSet.next()) {
            paymentRequestStatuses.put(statusesRowSet.getString("PMT_RQST_STAT_CD"), statusesRowSet.getString("PMT_RQST_STAT_DESC"));
        }
        
        LOG.debug("getPaymentRequestDocumentStatuses() exited");
        
        return paymentRequestStatuses;
    } catch (DataAccessException dae) {
        return paymentRequestStatuses;
    }
}
 
Example 41
Project: kfs   File: StatusCodeAndDescriptionForPurapDocumentsDaoJdbc.java   Source Code and License 6 votes vote down vote up
/**
 * @see org.kuali.kfs.module.purap.dataaccess.StatusCodeAndDescriptionForPurapDocumentsDao#getVendorCreditMemoDocumentStatuses()
 */
public Map<String, String> getVendorCreditMemoDocumentStatuses() {
    LOG.debug("getVendorCreditMemoDocumentStatuses() started");
    
    Map<String, String> vendorCreditMemoStatuses = new HashMap<String, String>();
    
    try {
        SqlRowSet statusesRowSet = getJdbcTemplate().queryForRowSet("SELECT * FROM AP_CRDT_MEMO_STAT_T ORDER BY CRDT_MEMO_STAT_CD"); 

        while (statusesRowSet.next()) {
            vendorCreditMemoStatuses.put(statusesRowSet.getString("CRDT_MEMO_STAT_CD"), statusesRowSet.getString("CRDT_MEMO_STAT_DESC"));
        }
        
        LOG.debug("getVendorCreditMemoDocumentStatuses() exited");
        
        return vendorCreditMemoStatuses;
    } catch (DataAccessException dae) {
        return vendorCreditMemoStatuses;
    }
}
 
Example 42
Project: kfs   File: StatusCodeAndDescriptionForPurapDocumentsDaoJdbc.java   Source Code and License 6 votes vote down vote up
/**
 * @see org.kuali.kfs.module.purap.dataaccess.StatusCodeAndDescriptionForPurapDocumentsDao#getLineItemReceivingDocumentStatuses()
 */
public Map<String, String> getLineItemReceivingDocumentStatuses() {
    LOG.debug("getLineItemReceivingDocumentStatuses() started");
    
    Map<String, String> lineItemReceivingStatuses = new HashMap<String, String>();
    
    try {
        SqlRowSet statusesRowSet = getJdbcTemplate().queryForRowSet("SELECT * FROM PUR_RCVNG_LN_STAT_T ORDER BY RCVNG_LN_STAT_CD"); 

        while (statusesRowSet.next()) {
            lineItemReceivingStatuses.put(statusesRowSet.getString("RCVNG_LN_STAT_CD"), statusesRowSet.getString("RCVNG_LN_STAT_DESC"));
        }
        
        LOG.debug("getLineItemReceivingDocumentStatuses() exited");
        
        return lineItemReceivingStatuses;
    } catch (DataAccessException dae) {
        return lineItemReceivingStatuses;
    }
}
 
Example 43
Project: plow   File: JobDaoImpl.java   Source Code and License 6 votes vote down vote up
@Override
public boolean isDispatchable(JobId job) {
    SqlRowSet row =  jdbc.queryForRowSet(HAS_PENDING_FRAMES, job.getJobId());
    if (!row.first()) {
        return true;
    }
    if (row.getInt("int_state") == JobState.FINISHED.ordinal()) {
        return true;
    }
    if (row.getInt("pending") == 0) {
        return true;
    }
    if (!row.getBoolean("bool_paused")) {
        return true;
    }
    return false;
}
 
Example 44
Project: InSpider   File: TagProcess.java   Source Code and License 6 votes vote down vote up
/**
 * Retrieve a set of columns for a table in a certain schema.
 */
private Set<String> retrieveColumns(Table table) {
	NamedParameterJdbcTemplate jdbc = new NamedParameterJdbcTemplate(dataSource);
	Map<String, String> params = new HashMap<String, String>();
	params.put("schema_name", table.schema());
	params.put("table_name", table.name());

	SqlRowSet columnResultSet = jdbc.queryForRowSet("select column_name from information_schema.columns where table_schema=:schema_name and table_name=:table_name", params);
	SortedSet<String> columnNames = new TreeSet<String>();
	while (columnResultSet.next()) {
		String columnName = columnResultSet.getString("column_name");
		if (!columnName.equals("id")) {
			columnNames.add(columnName);
		}
	}
	return columnNames;
}
 
Example 45
Project: appstatus   File: BatchDao.java   Source Code and License 6 votes vote down vote up
/**
 * Read batch object from result set.
 * 
 * @param srs
 * @return
 * @throws IOException
 * @throws SQLException
 */
private BdBatch mappinpBdbatch(SqlRowSet srs) throws SQLException,
		IOException {
	BdBatch bdBatch = new BdBatch();
	bdBatch.setUuid(srs.getString("UUID_BATCH"));
	bdBatch.setCurrentItem(srs.getString("ITEM"));
	bdBatch.setEndDate(srs.getDate("END_DATE"));
	bdBatch.setGroup(srs.getString("GROUP_BATCH"));
	bdBatch.setItemCount(srs.getLong("ITEMCOUNT"));
	bdBatch.setLastMessage(srs.getString("LAST_MSG"));
	bdBatch.setLastUpdate(srs.getDate("UPDATED"));
	bdBatch.setName(srs.getString("NAME_BATCH"));
	bdBatch.setProgress(srs.getFloat("PROGRESS"));
	bdBatch.setStartDate(srs.getDate("START_DATE"));
	bdBatch.setStatus(srs.getString("STATUS"));
	bdBatch.setSuccess(srs.getBoolean("SUCCESS"));

	// Clob
	Clob reject = (Clob) srs.getObject("REJECT");
	bdBatch.setReject(clobToString(reject));

	return bdBatch;
}
 
Example 46
Project: MOCHA   File: RandomOrderCheckCapabilityImpl.java   Source Code and License 6 votes vote down vote up
/**
 * Use Sring's getFdbDifJdbcTemplate() to retrieve a List of Numbers containing all GCN sequence numbers available for a
 * dosing order check.
 * <p>
 * Populates the dose route, dose type, and dose units from a row in FDB_DOSERANGECHECK for the given GCN sequence
 * number.
 * 
 * @param gcn GCN sequence number of drug with dosing information in FDB_DOSERANGECHECK
 * @param doseInformation {@link DoseInformation} to populate
 */
private void populateDoseInformation(BigInteger gcn, DoseInformation doseInformation) {
    String countSql = "SELECT COUNT(1) FROM FDB_DOSERANGECHECK WHERE GCNSEQNO = ? AND DOSELOWUNITS IS NOT NULL";
    int count = jdbcTemplate.queryForInt(countSql, new Object[] {gcn.intValue()});

    String sql = "SELECT DOSEROUTEID, DOSETYPEID, DOSELOWUNITS FROM FDB_DOSERANGECHECK WHERE GCNSEQNO = ? AND DOSELOWUNITS IS NOT NULL";

    SqlRowSet sqlRowSet = jdbcTemplate.queryForRowSet(sql, new Object[] {gcn.intValue()});
    sqlRowSet.absolute(randomPositiveInt(count) + 1);

    String doseRouteId = sqlRowSet.getString(1);
    String doseTypeId = sqlRowSet.getString(2);
    String doseLowUnits = sqlRowSet.getString(3);

    doseInformation.setRoute(getDoseRoute(doseRouteId));
    doseInformation.setDoseType(getDoseType(doseTypeId));
    doseInformation.setDoseUnit(getDoseUnit(doseLowUnits));
}
 
Example 47
Project: MOCHA   File: RandomOrderCheckTestCase.java   Source Code and License 6 votes vote down vote up
/**
 * Use Sring's getFdbDifJdbcTemplate() to retrieve a List of Numbers containing all GCN sequence numbers available for a
 * dosing order check.
 * <p>
 * Populates the dose route, dose type, and dose units from a row in FDB_DOSERANGECHECK for the given GCN sequence
 * number.
 * 
 * @param gcn GCN sequence number of drug with dosing information in FDB_DOSERANGECHECK
 * @param doseInformation {@link DoseInformation} to populate
 */
private void populateDoseInformation(BigInteger gcn, DoseInformation doseInformation) {
    String countSql = "SELECT COUNT(1) FROM FDB_DOSERANGECHECK WHERE GCNSEQNO = ? AND DOSELOWUNITS IS NOT NULL";
    int count = getFdbDifJdbcTemplate().queryForInt(countSql, new Object[] {gcn.intValue()});

    String sql = "SELECT DOSEROUTEID, DOSETYPEID, DOSELOWUNITS FROM FDB_DOSERANGECHECK WHERE GCNSEQNO = ? AND DOSELOWUNITS IS NOT NULL";

    SqlRowSet sqlRowSet = getFdbDifJdbcTemplate().queryForRowSet(sql, new Object[] {gcn.intValue()});
    sqlRowSet.absolute(randomPositiveInt(count) + 1);

    String doseRouteId = sqlRowSet.getString(1);
    String doseTypeId = sqlRowSet.getString(2);
    String doseLowUnits = sqlRowSet.getString(3);

    doseInformation.setRoute(getDoseRoute(doseRouteId));
    doseInformation.setDoseType(getDoseType(doseTypeId));
    doseInformation.setDoseUnit(getDoseUnit(doseLowUnits));
}
 
Example 48
Project: Lottery   File: CmsDataDaoImpl.java   Source Code and License 6 votes vote down vote up
public List<CmsTable> listTables() {
	String sql = "select table_name,table_comment,engine,table_rows,auto_increment from tables where table_schema='"
			+ db + "'";
	List<CmsTable> tables = new ArrayList<CmsTable>();
	SqlRowSet set = getJdbcTemplate().queryForRowSet(sql);
	while (set.next()) {
		CmsTable table = new CmsTable();
		table.setName(set.getString(1));
		table.setComment(set.getString(2).split(";")[0]);
		table.setEngine(set.getString(3));
		table.setRows(set.getInt(4));
		table.setAuto_increment(set.getInt(5));
		tables.add(table);
	}
	return tables;
}
 
Example 49
Project: Lottery   File: CmsDataDaoImpl.java   Source Code and License 6 votes vote down vote up
public CmsTable findTable(String tablename) {
	String sql = "select table_name,table_comment,engine,table_rows,auto_increment from tables where table_schema='"
			+ db + "' and table_name='" + tablename + "'";
	List<CmsTable> tables = new ArrayList<CmsTable>();
	SqlRowSet set = getJdbcTemplate().queryForRowSet(sql);
	while (set.next()) {
		CmsTable table = new CmsTable();
		table.setName(set.getString(1));
		table.setComment(set.getString(2).split(";")[0]);
		table.setEngine(set.getString(3));
		table.setRows(set.getInt(4));
		table.setAuto_increment(set.getInt(5));
		tables.add(table);
	}
	if (tables.size() > 0) {
		return tables.get(0);
	}else{
		return null;
	}
}
 
Example 50
Project: Lottery   File: CmsDataDaoImpl.java   Source Code and License 6 votes vote down vote up
public List<CmsField> listFields(String tablename) {
	String sql = "select column_name,column_type,column_default,column_key,column_comment,is_nullable,extra from columns where table_schema='"
			+ db + "' and table_name='" + tablename + "'";
	List<CmsField> fields = new ArrayList<CmsField>();
	SqlRowSet set = getJdbcTemplate().queryForRowSet(sql);
	while (set.next()) {
		CmsField field = new CmsField();
		field.setName(set.getString(1));
		field.setFieldType(set.getString(2));
		field.setFieldDefault(set.getString(3));
		field.setFieldProperty(set.getString(4));
		field.setComment(set.getString(5));
		field.setNullable(set.getString(6));
		field.setExtra(set.getString(7));
		fields.add(field);
	}
	return fields;
}
 
Example 51
Project: Lottery   File: CmsDataDaoImpl.java   Source Code and License 6 votes vote down vote up
public List<CmsConstraints> listConstraints(String tablename) {
	String sql = "select constraint_name,table_name,column_name,referenced_table_name,referenced_column_name from information_schema.KEY_COLUMN_USAGE where constraint_schema='"
			+ db + "' and table_name='" + tablename + "'";
	List<CmsConstraints> constraints = new ArrayList<CmsConstraints>();
	SqlRowSet set = getJdbcTemplate().queryForRowSet(sql);
	while (set.next()) {
		CmsConstraints constraint = new CmsConstraints();
		constraint.setName(set.getString(1));
		constraint.setTableName(set.getString(2));
		constraint.setColumnName(set.getString(3));
		constraint.setReferencedTableName(set.getString(4));
		constraint.setReferencedColumnName(set.getString(5));
		constraints.add(constraint);
	}
	return constraints;
}
 
Example 52
Project: Lottery   File: CmsDataBackDaoImpl.java   Source Code and License 6 votes vote down vote up
public List<CmsField> listFields(String tablename) {
	String sql = " desc  " + tablename;
	List<CmsField> fields = new ArrayList<CmsField>();
	SqlRowSet set = getJdbcTemplate().queryForRowSet(sql);
	while (set.next()) {
		CmsField field = new CmsField();
		field.setName(set.getString(1));
		field.setFieldType(set.getString(2));
		field.setNullable(set.getString(3));
		field.setFieldProperty(set.getString(4));
		field.setFieldDefault(set.getString(5));
		field.setExtra(set.getString(6));
		fields.add(field);
	}
	return fields;
}
 
Example 53
Project: prognosticator   File: HiveQueryImplTest.java   Source Code and License 6 votes vote down vote up
@Test
public void testRunQuery() throws Exception {
    final String queryString = "SELECT * FROM foo";

    NamedParameterJdbcTemplate template = mock(NamedParameterJdbcTemplate.class);

    HiveQueryImpl query = new HiveQueryImpl(template);

    Map<String, Object> parameterMap = new HashMap<String, Object>() {
        {
            put("param1", "string");
            put("param2", 123);
        }
    };

    SqlRowSet rowSet = mock(SqlRowSet.class);
    when(template.queryForRowSet(queryString, parameterMap)).thenReturn(rowSet);

    QueryCursor<Map<String, Object>> cursor = query.runQuery(queryString, parameterMap);

    Assert.assertNotNull(cursor);
}
 
Example 54
Project: factcast   File: PGLatestSerialFetcher.java   Source Code and License 5 votes vote down vote up
/**
 * 
 * @param id
 * @return 0, if no Fact is found,
 */
public long retrieveLatestSer() {

    try {
        SqlRowSet rs = jdbcTemplate.queryForRowSet(PGConstants.SELECT_LATEST_SER);
        if (rs.next()) {
            return rs.getLong(1);
        }
    } catch (EmptyResultDataAccessException meh) {
    }
    return 0;
}
 
Example 55
Project: OperatieBRP   File: AfnemerindicatieBatchStrategy.java   Source Code and License 5 votes vote down vote up
@Override
public void dumpHisAfnemerindicatieTabel(final File outputFile) {
    LOGGER.info("Genereer hisafnemerindicatie rijen naar {}", outputFile.getAbsolutePath());
    try (FileOutputStream fos = new FileOutputStream(outputFile)) {
        final SqlRowSet sqlRowSet = new JdbcTemplate(masterDataSource).queryForRowSet("select hpa.* from autaut.his_persafnemerindicatie hpa\n"
                + "inner join (select pa.id as afnemerindid \n"
                + "from autaut.persafnemerindicatie pa, autaut.levsautorisatie la where pa.levsautorisatie = la.id and la.dateinde is null) \n"
                + "as x on hpa.persafnemerindicatie = x.afnemerindid");
        while (sqlRowSet.next()) {
            IOUtils.write(String.format("%s,%s,%s,%s,%s,%s,%s,%s%n",
                    sqlRowSet.getString(INDEX_HIS_ID),
                    sqlRowSet.getString(INDEX_HIS_PERSAFNEMERINDICATIE),
                    sqlRowSet.getString(INDEX_HIS_TSREG),
                    StringUtils.defaultIfBlank(sqlRowSet.getString(INDEX_HIS_TSVERVAL), AfnemerindicatieConversie.NULL_VALUE),
                    StringUtils.defaultIfBlank(sqlRowSet.getString(INDEX_HIS_DIENSTINHOUD), AfnemerindicatieConversie.NULL_VALUE),
                    StringUtils.defaultIfBlank(sqlRowSet.getString(INDEX_HIS_DIENSTVERVAL), AfnemerindicatieConversie.NULL_VALUE),
                    StringUtils.defaultIfBlank(sqlRowSet.getString(INDEX_HIS_DATAANVANGMATERIELEPERIODE), AfnemerindicatieConversie.NULL_VALUE),
                    StringUtils.defaultIfBlank(sqlRowSet.getString(INDEX_HIS_DATEINDEVOLGEN), AfnemerindicatieConversie.NULL_VALUE)
            ), fos, StandardCharsets.UTF_8);
        }
    } catch (IOException e) {
        throw new IllegalStateException(e);
    }
}
 
Example 56
Project: stats-alfresco-on-database   File: LocalDaoImpl.java   Source Code and License 5 votes vote down vote up
@Override
@Transactional
public List<Long> selectLeafNode() throws SaodException {
	String query = sqlQueries.getQuery("select_leaf_node.sql");
	final SqlRowSet queryForRowSet = this.jdbcTemplate.queryForRowSet(query);

	final List<Long> ids = new ArrayList<>();
	while (queryForRowSet.next()) {
		ids.add(queryForRowSet.getLong(1));
	}

	return ids;
}
 
Example 57
Project: stats-alfresco-on-database   File: LocalDaoImpl.java   Source Code and License 5 votes vote down vote up
@Override
@Transactional
public List<Long> selectRootFolders() throws SaodException {
	String query = sqlQueries.getQuery("select_root_folders.sql");
	final SqlRowSet queryForRowSet = this.jdbcTemplate.queryForRowSet(query);

	final List<Long> ids = new ArrayList<>();
	while (queryForRowSet.next()) {
		ids.add(queryForRowSet.getLong(1));
	}

	return ids;
}
 
Example 58
Project: stats-alfresco-on-database   File: LocalDaoImpl.java   Source Code and License 5 votes vote down vote up
@Override
@Transactional
public List<Long> selectSubFolders(Long nodeid) throws SaodException {
	String query = sqlQueries.getQuery("select_sub_folders.sql");
	final SqlRowSet queryForRowSet = this.jdbcTemplate.queryForRowSet(query, nodeid);

	final List<Long> ids = new ArrayList<>();
	while (queryForRowSet.next()) {
		ids.add(queryForRowSet.getLong(1));
	}

	return ids;
}
 
Example 59
Project: stats-alfresco-on-database   File: AlfrescoDaoImpl.java   Source Code and License 5 votes vote down vote up
@Override
@Transactional
public Map<Long, Long> selectDirLocalSize() throws SaodException {
	String query = sqlQueries.getQuery("select_dir_local_size.sql");
	final SqlRowSet queryForRowSet = this.jdbcTemplate.queryForRowSet(query);

	final Map<Long, Long> libelle = new HashMap<>();
	while (queryForRowSet.next()) {
		libelle.put(queryForRowSet.getLong(1), queryForRowSet.getLong(2));
	}

	return libelle;
}
 
Example 60
Project: java-samples   File: QueryForRowSet.java   Source Code and License 5 votes vote down vote up
/**
 * D�monstration de l'utilisation d'un rowSet pour r�cup�rer un �l�ment
 */
public User getUser(final int id) {
    SqlRowSet rowset = jdbcTemplate.queryForRowSet("select * from users where id = ?", id);
    User user = null;
    if (rowset.first()) {
        user = new User();
        user.setId(rowset.getInt("ID"));
        user.setName(rowset.getString("NAME"));
        user.setMail(rowset.getString("EMAIL"));
    }
    return user;
}