use of com.khartec.waltz.schema.tables.ChangeInitiative.CHANGE_INITIATIVE in project waltz by khartec.
the class ChangeInitiativeGenerator method main.
public static void main(String[] args) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
DSLContext dsl = ctx.getBean(DSLContext.class);
List<Long> groupIds = dsl.select(APPLICATION_GROUP.ID).from(APPLICATION_GROUP).fetch(APPLICATION_GROUP.ID);
List<String> employeeIds = dsl.select(PERSON.EMPLOYEE_ID).from(PERSON).fetch(PERSON.EMPLOYEE_ID);
List<Long> orgUnitIds = dsl.select(ORGANISATIONAL_UNIT.ID).from(ORGANISATIONAL_UNIT).fetch(ORGANISATIONAL_UNIT.ID);
List<TableRecord<?>> records = LongStream.range(0, 400).mapToObj(i -> {
String name = randomPick(p1) + " " + randomPick(p2) + " " + randomPick(p3);
Long ouId = randomPick(orgUnitIds.toArray(new Long[0]));
return Tuple.tuple(i, name, ouId);
}).map(t -> buildChangeInitiativeRecord(t)).flatMap(r -> Stream.concat(Stream.of(r), buildLinks(r, groupIds, employeeIds))).collect(toList());
System.out.println("-- deleting");
dsl.deleteFrom(CHANGE_INITIATIVE).execute();
System.out.println("-- inserting");
dsl.batchInsert(records).execute();
System.out.println(" -- done");
}
use of com.khartec.waltz.schema.tables.ChangeInitiative.CHANGE_INITIATIVE in project waltz by khartec.
the class SqlServerChangeInitiativeSearch method search.
@Override
public List<ChangeInitiative> search(DSLContext dsl, String query, EntitySearchOptions options) {
List<String> terms = mkTerms(query);
if (terms.isEmpty()) {
return Collections.emptyList();
}
Condition nameCondition = terms.stream().map(term -> CHANGE_INITIATIVE.NAME.like("%" + term + "%")).collect(Collectors.reducing(DSL.trueCondition(), (acc, frag) -> acc.and(frag)));
List<ChangeInitiative> ciViaName = dsl.selectDistinct(CHANGE_INITIATIVE.fields()).from(CHANGE_INITIATIVE).where(nameCondition).orderBy(CHANGE_INITIATIVE.NAME).limit(options.limit()).fetch(ChangeInitiativeDao.TO_DOMAIN_MAPPER);
List<ChangeInitiative> ciViaFullText = dsl.select(CHANGE_INITIATIVE.fields()).from(CHANGE_INITIATIVE).where(JooqUtilities.MSSQL.mkContainsPrefix(terms)).limit(options.limit()).fetch(ChangeInitiativeDao.TO_DOMAIN_MAPPER);
return new ArrayList<>(orderedUnion(ciViaName, ciViaFullText));
}
Aggregations