org.jooq.lambda.tuple.Tuple Java Examples

The following examples show how to use org.jooq.lambda.tuple.Tuple. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SimilarityComputerTest.java    From metanome-algorithms with Apache License 2.0 6 votes vote down vote up
@Test
public void test() {
	doReturn(Double.valueOf(0.13)).when(similarityMeasure).calculateSimilarity(Integer.valueOf(1), Integer.valueOf(3));
	doReturn(Double.valueOf(0.14)).when(similarityMeasure).calculateSimilarity(Integer.valueOf(1), Integer.valueOf(4));
	doReturn(Double.valueOf(0.23)).when(similarityMeasure).calculateSimilarity(Integer.valueOf(2), Integer.valueOf(3));
	doReturn(Double.valueOf(0.24)).when(similarityMeasure).calculateSimilarity(Integer.valueOf(2), Integer.valueOf(4));
	when(generator.generate(Arrays.asList(Integer.valueOf(1), Integer.valueOf(2)), Arrays.asList(Integer.valueOf(3), Integer.valueOf(4))))
		.thenReturn(new Result<>(Stream.of(
			Tuple.tuple(Integer.valueOf(1), Arrays.asList(Integer.valueOf(3), Integer.valueOf(4))),
			Tuple.tuple(Integer.valueOf(2), Arrays.asList(Integer.valueOf(3), Integer.valueOf(4)))), true));
	SimilarityComputer<Integer> computer = createComputer();
	Collection<Similarity<Integer>> similarities = computer
		.compute(similarityMeasure, Arrays.asList(Integer.valueOf(1), Integer.valueOf(2)), Arrays.asList(Integer.valueOf(3), Integer.valueOf(4)))
		.getSimilarities()
		.collect(Collectors.toList());
	assertThat(similarities).hasSize(2);
	assertThat(similarities)
		.contains(new Similarity<>(Integer.valueOf(1), Arrays.asList(new To<>(Integer.valueOf(3), 0.13), new To<>(Integer.valueOf(4), 0.14))));
	assertThat(similarities)
		.contains(new Similarity<>(Integer.valueOf(2), Arrays.asList(new To<>(Integer.valueOf(3), 0.23), new To<>(Integer.valueOf(4), 0.24))));
}
 
Example #2
Source File: CollectionUtilsTest.java    From metanome-algorithms with Apache License 2.0 6 votes vote down vote up
@Test
public void testCrossProduct() {
	assertThat(CollectionUtils.crossProduct(Arrays.asList(1, 2, 3))).hasSize(1 + 2 + 3);
	assertThat(CollectionUtils.crossProduct(Arrays.asList(1, 2, 3)))
		.contains(Tuple.tuple(1, 1));
	assertThat(CollectionUtils.crossProduct(Arrays.asList(1, 2, 3)))
		.contains(Tuple.tuple(1, 2));
	assertThat(CollectionUtils.crossProduct(Arrays.asList(1, 2, 3)))
		.contains(Tuple.tuple(1, 3));
	assertThat(CollectionUtils.crossProduct(Arrays.asList(1, 2, 3)))
		.contains(Tuple.tuple(2, 2));
	assertThat(CollectionUtils.crossProduct(Arrays.asList(1, 2, 3)))
		.contains(Tuple.tuple(2, 3));
	assertThat(CollectionUtils.crossProduct(Arrays.asList(1, 2, 3)))
		.contains(Tuple.tuple(3, 3));
}
 
Example #3
Source File: ValueTypeTest.java    From json2java4idea with Apache License 2.0 6 votes vote down vote up
@Parameters(name = "{0}")
public static Collection<Tuple3<ValueType, Object, Class>> fixtures() {
    return Arrays.asList(
            Tuple.tuple(ValueType.NULL, null, JsonNull.class),
            Tuple.tuple(ValueType.BOOLEAN, true, JsonBoolean.class),
            Tuple.tuple(ValueType.INT, 42, JsonNumber.class),
            Tuple.tuple(ValueType.LONG, 42L, JsonNumber.class),
            Tuple.tuple(ValueType.FLOAT, 4.2f, JsonNumber.class),
            Tuple.tuple(ValueType.DOUBLE, 4.2d, JsonNumber.class),
            Tuple.tuple(ValueType.BIG_INTEGER, BigInteger.ONE, JsonNumber.class),
            Tuple.tuple(ValueType.BIG_DECIMAL, BigDecimal.ONE, JsonNumber.class),
            Tuple.tuple(ValueType.STRING, "foo", JsonString.class),
            Tuple.tuple(ValueType.ARRAY, Collections.emptyList(), JsonArray.class),
            Tuple.tuple(ValueType.OBJECT, Collections.emptyMap(), JsonObject.class)
    );
}
 
Example #4
Source File: ValueTypeTest.java    From json2java4idea with Apache License 2.0 6 votes vote down vote up
@Parameters(name = "{0}")
public static Collection<Tuple3<ValueType, Object, String>> fixtures() {
    return Arrays.asList(
            Tuple.tuple(ValueType.NULL, "null", "Value 'null' is not a null"),
            Tuple.tuple(ValueType.BOOLEAN, null, "Value 'null' is not a boolean"),
            Tuple.tuple(ValueType.INT, null, "Value 'null' is not an int"),
            Tuple.tuple(ValueType.LONG, null, "Value 'null' is not a long"),
            Tuple.tuple(ValueType.FLOAT, null, "Value 'null' is not a float"),
            Tuple.tuple(ValueType.DOUBLE, null, "Value 'null' is not a double"),
            Tuple.tuple(ValueType.BIG_INTEGER, null, "Value 'null' is not a big integer"),
            Tuple.tuple(ValueType.BIG_DECIMAL, null, "Value 'null' is not a big decimal"),
            Tuple.tuple(ValueType.STRING, null, "Value 'null' is not a string"),
            Tuple.tuple(ValueType.ARRAY, null, "Value 'null' is not an array"),
            Tuple.tuple(ValueType.OBJECT, null, "Value 'null' is not an object")
    );
}
 
Example #5
Source File: ChangeReporter.java    From waltz with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws IOException {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    ApplicationIdSelectorFactory selectorFactory = new ApplicationIdSelectorFactory();

    LocalDateTime exerciseStart = LocalDateTime.of(2018, 06, 04, 0, 1).truncatedTo(ChronoUnit.DAYS);
    LocalDateTime dayBeforeYesterday = LocalDateTime.now().truncatedTo(ChronoUnit.DAYS).minusDays(1);
    LocalDateTime yesterday = LocalDateTime.now().truncatedTo(ChronoUnit.DAYS);

    EntityReference appGroupRef = EntityReference.mkRef(EntityKind.APP_GROUP, 10862); // BCBS239
    Select<Record1<Long>> appSelector = mkSelector(selectorFactory, appGroupRef);

    Tuple3<String, LocalDateTime, LocalDateTime> dayPeriod = Tuple.tuple("day", dayBeforeYesterday, yesterday);
    Tuple3<String, LocalDateTime, LocalDateTime> cumulativePeriod = Tuple.tuple("cumulative", exerciseStart, yesterday);

    dumpReport(dsl, dayPeriod, appGroupRef, appSelector);
    dumpReport(dsl, cumulativePeriod, appGroupRef, appSelector);
}
 
Example #6
Source File: AssetCostDao.java    From waltz with Apache License 2.0 6 votes vote down vote up
public List<Tuple2<Long, BigDecimal>> calculateCombinedAmountsForSelector(int year, Select<Record1<Long>> appIdSelector) {
    checkNotNull(appIdSelector, "appIdSelector cannot be null");

    Field<BigDecimal> totalAmount = DSL.sum(ASSET_COST.AMOUNT).as("total_amount");

    Condition condition = ASSET_COST.YEAR.eq(year)
            .and(APPLICATION.ID.in(appIdSelector));

    return dsl.select(APPLICATION.ID, totalAmount)
            .from(ASSET_COST)
            .innerJoin(APPLICATION)
            .on(APPLICATION.ASSET_CODE.eq(ASSET_COST.ASSET_CODE))
            .where(dsl.renderInlined(condition))
            .groupBy(APPLICATION.ID)
            .fetch(r -> Tuple.tuple(r.value1(), r.value2()));
}
 
Example #7
Source File: MeasurableRatingPlannedDecommissionDao.java    From waltz with Apache License 2.0 6 votes vote down vote up
public Tuple2<Operation, Boolean> save(EntityReference entityReference, long measurableId, DateFieldChange dateChange, String userName) {
    MeasurableRatingPlannedDecommissionRecord existingRecord = dsl
            .selectFrom(MEASURABLE_RATING_PLANNED_DECOMMISSION)
            .where(mkRefCondition(entityReference)
                    .and(MEASURABLE_RATING_PLANNED_DECOMMISSION.MEASURABLE_ID.eq(measurableId)))
            .fetchOne();

    if (existingRecord != null) {
        updateDecommDateOnRecord(existingRecord, dateChange, userName);
        boolean updatedRecord = existingRecord.update() == 1;

        return Tuple.tuple(Operation.UPDATE, updatedRecord);
    } else {
        MeasurableRatingPlannedDecommissionRecord record = dsl.newRecord(MEASURABLE_RATING_PLANNED_DECOMMISSION);
        updateDecommDateOnRecord(record, dateChange, userName);
        record.setCreatedAt(DateTimeUtilities.nowUtcTimestamp());
        record.setCreatedBy(userName);
        record.setEntityId(entityReference.id());
        record.setEntityKind(entityReference.kind().name());
        record.setMeasurableId(measurableId);
        boolean recordsInserted = record.insert() == 1;

        return Tuple.tuple(Operation.ADD, recordsInserted);
    }
}
 
Example #8
Source File: RankSysDataModel.java    From rival with Apache License 2.0 5 votes vote down vote up
@Override
public void addPreference(U u, I i, Double d) {
    if (model != null) {
        throw new IllegalArgumentException("DataModel already generated. It is not possible to add more information.");
    }
    users.add(u);
    items.add(i);
    tuples.add(Tuple.tuple(u, i, d));
}
 
Example #9
Source File: SortedNeighborhoodPairGenerator.java    From metanome-algorithms with Apache License 2.0 5 votes vote down vote up
private Tuple2<T, Collection<T>> generatePairs(T leftValue) {
	Collection<T> window = StreamUtils.seq(upperWindow)
		.concat(getCurrent())
		.concat(lowerWindow)
		.map(ValueWrapper::getValue)
		.toList();
	return Tuple.tuple(leftValue, window);
}
 
Example #10
Source File: SimpleBinaryPreferencesReader.java    From RankSys with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public <U, I> Stream<Tuple3<U, I, Double>> read(InputStream in, Parser<U> up, Parser<I> ip) {
    return new BufferedReader(new InputStreamReader(in)).lines().map(line -> {
        CharSequence[] tokens = split(line, '\t', 3);
        U user = up.parse(tokens[0]);
        I item = ip.parse(tokens[1]);

        return Tuple.tuple(user, item, 1.0);
    });
}
 
Example #11
Source File: SimpleRatingPreferencesReader.java    From RankSys with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public <U, I> Stream<Tuple3<U, I, Double>> read(InputStream in, Parser<U> up, Parser<I> ip) {
    return new BufferedReader(new InputStreamReader(in)).lines().map(line -> {
        CharSequence[] tokens = split(line, '\t', 4);
        U user = up.parse(tokens[0]);
        I item = ip.parse(tokens[1]);
        double value = parseDouble(tokens[2].toString());

        return Tuple.tuple(user, item, value);
    });
}
 
Example #12
Source File: SimpleFeaturesReader.java    From RankSys with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public <I, F> Stream<Tuple3<I, F, Double>> read(InputStream in, Parser<I> ip, Parser<F> fp) {
    return new BufferedReader(new InputStreamReader(in)).lines().map(line -> {
        String[] tokens = line.split("\t", 3);
        I item = ip.parse(tokens[0]);
        F feat = fp.parse(tokens[1]);

        return Tuple.tuple(item, feat, 1.0);
    });
}
 
Example #13
Source File: UsageInfoUtilities.java    From waltz with Apache License 2.0 5 votes vote down vote up
public static SystemChangeSet<UsageInfo, UsageKind> mkChangeSet(Set<UsageInfo> base, Set<UsageInfo> replacements) {

        Set<UsageKind> baseKinds = SetUtilities.map(base, ui -> ui.kind());
        Set<UsageKind> replacementKinds = SetUtilities.map(replacements, ui -> ui.kind());

        Set<UsageKind> newKinds = SetUtilities.minus(replacementKinds, baseKinds);


        Set<UsageKind> deletes = replacements.stream()
                .filter(ui -> ! ui.kind().isReadOnly())
                .filter(ui -> ! ui.isSelected())  // if it is selected we can't delete
                .filter(ui -> StringUtilities.isEmpty(ui.description()))
                .map(r -> r.kind())
                .collect(Collectors.toSet());

        Set<UsageInfo> updates = intersection(baseKinds, replacementKinds)
                .stream()
                .map(potentiallyUpdatedKind -> Tuple.tuple(
                        find(ui -> ui.kind() == potentiallyUpdatedKind, base),
                        find(ui -> ui.kind() == potentiallyUpdatedKind, replacements)))
                .filter(t -> t.v1.isPresent() && t.v2.isPresent())
                .filter(t -> ! t.v1.get().equals(t.v2.get()))
                .map(t -> t.v2().get())
                .filter(ui -> ! deletes.contains(ui.kind()))
                .collect(Collectors.toSet());

        Collection<UsageInfo> inserts = replacements.stream()
                .filter(r -> newKinds.contains(r.kind()))
                .filter(r -> StringUtilities.notEmpty(r.description()) || r.isSelected())
                .collect(Collectors.toSet());

        return ImmutableSystemChangeSet.<UsageInfo, UsageKind>builder()
                .inserts(inserts)
                .updates(updates)
                .deletes(deletes)
                .build();
    }
 
Example #14
Source File: LogicalFlowDao.java    From waltz with Apache License 2.0 5 votes vote down vote up
public List<LogicalFlow> addFlows(List<LogicalFlow> flows, String user) {
    Condition condition = flows
            .stream()
            .map(t -> isSourceCondition(t.source())
                    .and(isTargetCondition(t.target()))
                    .and(LOGICAL_FLOW.ENTITY_LIFECYCLE_STATUS.eq(REMOVED.name())
                            .or(LOGICAL_FLOW.IS_REMOVED)))
            .reduce((a, b) -> a.or(b))
            .get();

    List<LogicalFlow> removedFlows = baseQuery()
            .where(condition)
            .fetch(TO_DOMAIN_MAPPER);

    if(removedFlows.size() > 0) {
        restoreFlows(removedFlows, user);
    }

    Map<Tuple2<EntityReference, EntityReference>, LogicalFlow> existing = removedFlows
            .stream()
            .collect(Collectors.toMap(f -> Tuple.tuple(f.source(), f.target()), f -> f));


    List<LogicalFlow> addedFlows = flows
            .stream()
            .filter(f -> !existing.containsKey(Tuple.tuple(f.source(), f.target())))
            .map(f -> {
                LogicalFlowRecord record = TO_RECORD_MAPPER.apply(f, dsl);
                record.store();
                return ImmutableLogicalFlow
                        .copyOf(f)
                        .withId(record.getId());
            })
            .collect(toList());


    addedFlows.addAll(removedFlows);
    return addedFlows;
}
 
Example #15
Source File: EntityRelationshipUtilities.java    From waltz with Apache License 2.0 5 votes vote down vote up
public static Optional<EntityRelationshipKey> mkEntityRelationshipKey(EntityReference entityA,
                                                                      EntityReference entityB,
                                                                      RelationshipKind relationshipKind,
                                                                      boolean validate) {
    checkNotNull(relationshipKind, "relationshipKind cannot be null");
    checkNotNull(entityA, "entityA cannot be null");
    checkNotNull(entityB, "entityB cannot be null");

    if (! validate) {
        return Optional.of(ImmutableEntityRelationshipKey.builder()
                .a(entityA)
                .b(entityB)
                .relationshipKind(relationshipKind.name())
                .build());
    }

    // given A, B and a relationship kind -> return the valid entity relationship
    Set<Tuple2<EntityKind, EntityKind>> allowedEntityKinds = relationshipKind.getAllowedEntityKinds();

    Tuple2<EntityKind, EntityKind> exact = Tuple.tuple(entityA.kind(), entityB.kind());
    Tuple2<EntityKind, EntityKind> opposite = Tuple.tuple(entityB.kind(), entityA.kind());

    if (allowedEntityKinds.contains(exact)) {
        return Optional.of(ImmutableEntityRelationshipKey.builder()
                .a(entityA)
                .b(entityB)
                .relationshipKind(relationshipKind.name())
                .build());
    } else if (allowedEntityKinds.contains(opposite)){
        return Optional.of(ImmutableEntityRelationshipKey.builder()
                .a(entityB)
                .b(entityA)
                .relationshipKind(relationshipKind.name())
                .build());
    } else {
        return Optional.empty();
    }
}
 
Example #16
Source File: MeasurableRatingGenerator.java    From waltz with Apache License 2.0 5 votes vote down vote up
@Override
public Map<String, Integer> create(ApplicationContext ctx) {

    DSLContext dsl = getDsl(ctx);


    List<Long> appIds = getAppIds(dsl);
    List<Long> mIds = dsl
            .select(MEASURABLE.ID)
            .from(MEASURABLE)
            .where(MEASURABLE.CONCRETE.isTrue())
            .fetch()
            .getValues(MEASURABLE.ID);



    List<MeasurableRatingRecord> records = appIds.stream()
            .flatMap(appId -> randomlySizedIntStream(0, MAX_RATINGS_PER_APP)
                            .mapToObj(idx -> Tuple.tuple(appId, randomPick(mIds))))
            .map(t -> {
                MeasurableRatingRecord record = dsl.newRecord(MEASURABLE_RATING);
                record.setEntityId(t.v1);
                record.setEntityKind(EntityKind.APPLICATION.name());
                record.setRating(randomPick("R", "A", "G"));
                record.setMeasurableId(t.v2);
                record.setLastUpdatedBy("admin");
                record.setProvenance(SAMPLE_DATA_PROVENANCE);
                return record;
            })
            .collect(Collectors.toList());

    Set<MeasurableRatingRecord> dedupedRecords = uniqBy(
            records,
            r -> Tuple.tuple(r.getMeasurableId(), r.getEntityId()));

    dsl.batchStore(dedupedRecords).execute();

    return null;
}
 
Example #17
Source File: ValueTypeTest.java    From json2java4idea with Apache License 2.0 5 votes vote down vote up
@Parameters(name = "{0}")
public static Collection<Tuple3<ValueType, Object, Boolean>> fixtures() {
    return Arrays.asList(
            Tuple.tuple(ValueType.NULL, null, true),
            Tuple.tuple(ValueType.NULL, "null", false),
            Tuple.tuple(ValueType.BOOLEAN, true, true),
            Tuple.tuple(ValueType.BOOLEAN, "true", false),
            Tuple.tuple(ValueType.INT, 1024, true),
            Tuple.tuple(ValueType.INT, 1024L, false),
            Tuple.tuple(ValueType.LONG, 1024L, true),
            Tuple.tuple(ValueType.LONG, 1024, false),
            Tuple.tuple(ValueType.FLOAT, 1.0f, true),
            Tuple.tuple(ValueType.FLOAT, 1.0d, false),
            Tuple.tuple(ValueType.DOUBLE, 1.0d, true),
            Tuple.tuple(ValueType.DOUBLE, 1.0f, false),
            Tuple.tuple(ValueType.BIG_INTEGER, BigInteger.ONE, true),
            Tuple.tuple(ValueType.BIG_INTEGER, 1, false),
            Tuple.tuple(ValueType.BIG_DECIMAL, BigDecimal.ONE, true),
            Tuple.tuple(ValueType.BIG_DECIMAL, 1, false),
            Tuple.tuple(ValueType.STRING, "text", true),
            Tuple.tuple(ValueType.STRING, null, false),
            Tuple.tuple(ValueType.ARRAY, Collections.singletonList("test"), true),
            Tuple.tuple(ValueType.ARRAY, null, false),
            Tuple.tuple(ValueType.OBJECT, Collections.singletonMap("key", "test"), true),
            Tuple.tuple(ValueType.OBJECT, null, false)
    );
}
 
Example #18
Source File: BulkRoleAssign.java    From waltz with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    UserRoleService userRoleService = ctx.getBean(UserRoleService.class);

    Set<String> defaultRoles = SetUtilities.asSet(
            SystemRole.BOOKMARK_EDITOR.name(),
            SystemRole.LOGICAL_DATA_FLOW_EDITOR.name(),
            SystemRole.LINEAGE_EDITOR.name());

    Set<String> mustHaveRoles = SetUtilities.asSet(
            SystemRole.TAXONOMY_EDITOR.name(),
            SystemRole.CAPABILITY_EDITOR.name(),
            SystemRole.RATING_EDITOR.name());

    InputStream inputStream = BulkRoleAssign.class.getClassLoader().getResourceAsStream("bulk-role-assign-example.txt");
    Set<Tuple2<String, Set<String>>> updates = IOUtilities
            .streamLines(inputStream)
            .map(d -> d.toLowerCase().trim())
            .map(d -> Tuple.tuple(d, userRoleService.getUserRoles(d)))
            .map(t -> t.map2(existingRoles -> union(existingRoles, defaultRoles, mustHaveRoles)))
            .collect(Collectors.toSet());

    System.out.printf("About to update: %d user-role mappings\n", updates.size());
    updates.forEach(t -> userRoleService.updateRoles("admin", t.v1, t.v2));
    System.out.println("Finished updating mappings");
}
 
Example #19
Source File: AllocationHarness.java    From waltz with Apache License 2.0 5 votes vote down vote up
private static Tuple4<Application, MeasurableCategory, List<Measurable>, AllocationScheme> setup(DSLContext dsl,
                                                                                                 AllocationSchemeService schemesService,
                                                                                                 MeasurableService measurableService,
                                                                                                 MeasurableCategoryDao categoryDao,
                                                                                                 ApplicationService applicationService) {
    deleteAll(dsl);
    Application app = mkApp(dsl, applicationService);
    MeasurableCategory category = mkCategory(dsl, categoryDao);
    List<Measurable> measurables = mkMeasurables(measurableService, category);
    AllocationScheme scheme = mkScheme(schemesService, category);

    return Tuple.tuple(app,category,measurables,scheme);
}
 
Example #20
Source File: ScenarioRatingImporter.java    From waltz with Apache License 2.0 5 votes vote down vote up
private void ensureScenarioAxes(List<Measurable> measurables,
                                Roadmap roadmap,
                                Scenario scenario,
                                List<ScenarioRatingRow> ratingRows) {
    Collection<ScenarioAxisItem> scenarioAxes = scenarioAxisItemDao.findForScenarioId(scenario.id().get());
    Map<Long, Measurable> measurablesById = indexBy(m -> m.id().get(), measurables);
    Map<String, ScenarioAxisItem> scenarioAxesByName = scenarioAxes.stream()
            .map(sa -> Tuple.tuple( lower( measurablesById.get(sa.domainItem().id()).name() ), sa))
            .collect(toMap(t -> t.v1(), t -> t.v2()));

    // check and create any missing columns
    addMissingColumns(measurables, ratingRows, roadmap, scenarioAxisItemDao,  scenarioAxesByName, scenario);
    addMissingRows(measurables, ratingRows, roadmap, scenarioAxisItemDao,  scenarioAxesByName, scenario);
}
 
Example #21
Source File: PhysicalFlowGenerator.java    From waltz with Apache License 2.0 4 votes vote down vote up
@Override
public Map<String, Integer> create(ApplicationContext ctx) {
    DSLContext dsl = getDsl(ctx);

    List<PhysicalSpecification> specifications = dsl
            .select(PHYSICAL_SPECIFICATION.fields())
            .select(owningEntityNameField)
            .from(PHYSICAL_SPECIFICATION)
            .fetch(PhysicalSpecificationDao.TO_DOMAIN_MAPPER);

    List<String> transportKinds = dsl
            .select(ENUM_VALUE.KEY)
            .from(ENUM_VALUE)
            .where(ENUM_VALUE.TYPE.eq(EnumValueKind.TRANSPORT_KIND.dbValue()))
            .fetch(ENUM_VALUE.KEY);

    List<Tuple3<Long, Long, Long>> allLogicalFLows = dsl
            .select(
                LOGICAL_FLOW.ID,
                LOGICAL_FLOW.SOURCE_ENTITY_ID,
                LOGICAL_FLOW.TARGET_ENTITY_ID)
            .from(LOGICAL_FLOW)
            .fetch(r -> Tuple.tuple(
                    r.getValue(LOGICAL_FLOW.ID),
                    r.getValue(LOGICAL_FLOW.SOURCE_ENTITY_ID),
                    r.getValue(LOGICAL_FLOW.TARGET_ENTITY_ID)));

    Map<Long, Collection<Long>> logicalFlowIdsBySourceApp = groupBy(
            t -> t.v2(),
            t -> t.v1(),
            allLogicalFLows);


    final int flowBatchSize = 100000;
    List<PhysicalFlowRecord> flowBatch = new ArrayList<PhysicalFlowRecord>((int) (flowBatchSize * 1.2));

    for (PhysicalSpecification spec : specifications) {
        Collection<Long> relatedLogicalFlowsIds = logicalFlowIdsBySourceApp.get(spec.owningEntity().id());
        if (!isEmpty(relatedLogicalFlowsIds)) {
            List<PhysicalFlowRecord> physicalFlowRecords = mkPhysicalFlowRecords(spec, new LinkedList<>(relatedLogicalFlowsIds), transportKinds);
            flowBatch.addAll(physicalFlowRecords);
        }

        if(flowBatch.size() >= flowBatchSize) {
            log(String.format("--- saving records: count: %s", flowBatch.size()));
            dsl.batchInsert(flowBatch).execute();
            flowBatch.clear();
        }
    }

    log(String.format("--- saving records: count: %s", flowBatch.size()));
    dsl.batchInsert(flowBatch).execute();
    flowBatch.clear();
    log("---done");   return null;
}
 
Example #22
Source File: DefaultNamePolicyTest.java    From json2java4idea with Apache License 2.0 4 votes vote down vote up
@Parameters(name = "{0}")
public static Collection<Tuple4<DefaultNamePolicy, String, TypeName, String>> fixtures() {
    return Arrays.asList(
            Tuple.tuple(
                    DefaultNamePolicy.CLASS,
                    "class_name",
                    TypeName.OBJECT,
                    "ClassName"
            ),
            Tuple.tuple(
                    DefaultNamePolicy.METHOD,
                    "method_name",
                    TypeName.OBJECT,
                    "getMethodName"
            ),
            Tuple.tuple(
                    DefaultNamePolicy.METHOD,
                    "method_name",
                    TypeName.BOOLEAN,
                    "isMethodName"
            ),
            Tuple.tuple(
                    DefaultNamePolicy.METHOD,
                    "method_name",
                    ClassName.get(Boolean.class),
                    "isMethodName"
            ),
            Tuple.tuple(
                    DefaultNamePolicy.FIELD,
                    "field_name",
                    TypeName.OBJECT,
                    "fieldName"
            ),
            Tuple.tuple(
                    DefaultNamePolicy.PARAMETER,
                    "parameter_name",
                    TypeName.OBJECT,
                    "parameterName"
            )
    );
}
 
Example #23
Source File: DefaultNamePolicyTest.java    From json2java4idea with Apache License 2.0 4 votes vote down vote up
@Parameters(name = "{0}")
public static Collection<Tuple3<String, CaseFormat, String>> fixtures() {
    return Arrays.asList(
            Tuple.tuple(
                    "this is a lower space case",
                    CaseFormat.LOWER_HYPHEN,
                    "this-is-a-lower-space-case"
            ),
            Tuple.tuple(
                    "THIS IS A UPPER SPACE CASE",
                    CaseFormat.LOWER_HYPHEN,
                    "this-is-a-upper-space-case"
            ),
            Tuple.tuple(
                    "this_is_a_lower_snake_case",
                    CaseFormat.LOWER_HYPHEN,
                    "this-is-a-lower-snake-case"
            ),
            Tuple.tuple(
                    "THIS_IS_A_UPPER_SNAKE_CASE",
                    CaseFormat.LOWER_HYPHEN,
                    "this-is-a-upper-snake-case"
            ),
            Tuple.tuple(
                    "this-is-a-lower-kebab-case",
                    CaseFormat.LOWER_HYPHEN,
                    "this-is-a-lower-kebab-case"
            ),
            Tuple.tuple(
                    "THIS-IS-A-UPPER-KEBAB-CASE",
                    CaseFormat.LOWER_HYPHEN,
                    "this-is-a-upper-kebab-case"
            ),
            Tuple.tuple(
                    "thisIsALowerCamelCase",
                    CaseFormat.LOWER_HYPHEN,
                    "this-is-a-lower-camel-case"
            ),
            Tuple.tuple(
                    "ThisIsAUpperCamelCase",
                    CaseFormat.LOWER_HYPHEN,
                    "this-is-a-upper-camel-case"
            ),
            Tuple.tuple(
                    "THIS is-A mix-leTTer_CASe",
                    CaseFormat.LOWER_HYPHEN,
                    "this-is-a-mix-letter-case"
            ),
            Tuple.tuple(
                    "THIS.iS_A RaND0m Letter$ -case_!",
                    CaseFormat.LOWER_HYPHEN,
                    "this-is-a-rand0m-letter$-case"
            ),
            Tuple.tuple(
                    "これはラテン文字ではありません。",
                    CaseFormat.LOWER_HYPHEN,
                    ""
            )
    );
}
 
Example #24
Source File: InvolvementImporter.java    From waltz with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) throws IOException {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    ApplicationService applicationService = ctx.getBean(ApplicationService.class);
    PersonService personService = ctx.getBean(PersonService.class);

    Map<String, Application> appsByExtId = indexBy(
            a -> a.assetCode().orElse(null),
            applicationService.findAll());

    Map<String, Person> peopleByName= indexBy(
            p -> toSurnameFirstname(p.displayName()).toLowerCase(),
            personService.all());

    Siphon<String[]> incorrectSizeSiphon = mkSiphon(arr -> arr.length != 3);
    Siphon<Tuple2<String ,?>> unknownAppSiphon = mkSiphon(t -> ! appsByExtId.containsKey(t.v1));
    Siphon<Tuple2<?, String>> unknownPersonSiphon = mkSiphon(t -> ! peopleByName.containsKey(t.v2.toLowerCase()));
    Siphon<Tuple2<Application ,?>> retiredAppSiphon = mkSiphon(t -> t.v1.lifecyclePhase() == LifecyclePhase.RETIRED);

    List<Tuple2<Application, Person>> r = IOUtilities
            .streamLines(classLoader.getResourceAsStream(fileName))
            .map(line -> line.split("\t"))
            .filter(d -> incorrectSizeSiphon.test(d))
            .map(arr -> Tuple.tuple(arr[1], arr[0]))
            .filter(t -> unknownAppSiphon.test(t))
            .map(t -> t.map1(extId -> appsByExtId.get(extId)))
            .filter(t -> retiredAppSiphon.test(t))
            .filter(t -> unknownPersonSiphon.test(t))
            .map(t -> t.map2(n -> peopleByName.get(n.toLowerCase())))
            .collect(Collectors.toList());

    Set<Application> distinctApps = r.stream().map(t -> t.v1).distinct().collect(Collectors.toSet());
    Set<Person> distinctPeople = r.stream().map(t -> t.v2).distinct().collect(Collectors.toSet());

    System.out.println("----");
    System.out.println("Wrong size count: "+ incorrectSizeSiphon.getResults().size());
    System.out.println("Apps not found count: "+ unknownAppSiphon.getResults().size());
    System.out.println("Retired app count: "+ retiredAppSiphon.getResults().size());
    System.out.println("Person not found count: "+ unknownPersonSiphon.getResults().size());
    System.out.println("----");
    System.out.println("Good record count: "+r.size());
    System.out.println("Distinct App count: "+distinctApps.size());
    System.out.println("Distinct People count: "+distinctPeople.size());

    Map<String, Long> unknownPersonCounts = countBy(Tuple2::v2, unknownPersonSiphon.getResults());
    DebugUtilities.dump(unknownPersonCounts);

}
 
Example #25
Source File: ScenarioRatingImporter.java    From waltz with Apache License 2.0 4 votes vote down vote up
private List<ScenarioRatingItemRecord> mkScenarioRatingRecords(List<Measurable> measurables,
                                                               Map<String, RagName> ratingsByName,
                                                               List<ScenarioRatingRow> rows,
                                                               Scenario scenario) {
    Collection<ScenarioAxisItem> scenarioAxes = scenarioAxisItemDao.findForScenarioId(scenario.id().get());
    Map<Long, Measurable> measurablesById = indexBy(m -> m.id().get(), measurables);
    Map<String, ScenarioAxisItem> scenarioAxesByName = scenarioAxes.stream()
            .map(sa -> Tuple.tuple(lower(measurablesById.get(sa.domainItem().id()).name()), sa))
            .collect(toMap(t -> t.v1(), t -> t.v2()));

    return rows.stream()
            .map(r -> {
                ScenarioAxisItem columnAxis = scenarioAxesByName.get(lower(r.column()));
                checkNotNull(columnAxis, "columnAxis cannot be null");
                checkTrue(columnAxis.axisOrientation().equals(AxisOrientation.COLUMN), "column does not match a oolumn axis");

                ScenarioAxisItem rowAxis = scenarioAxesByName.get(lower(r.row()));
                checkNotNull(rowAxis, "rowAxis cannot be null");
                checkTrue(rowAxis.axisOrientation().equals(AxisOrientation.ROW), "row does not match a row axis");

                Application app = assetCodeToApplicationMap.get(r.assetCode());
                checkNotNull(app, String.format("Application with asset code[%s] cannot be null", r.assetCode()));

                RagName rating = ratingsByName.get(lower(r.rating()));
                checkNotNull(rating, String.format("rating [%s] cannot be null", r.rating()));

                ScenarioRatingItemRecord record = new ScenarioRatingItemRecord();
                record.setScenarioId(scenario.id().get());
                record.setRating(rating.rating().toString());
                record.setDomainItemKind(EntityKind.APPLICATION.name());
                record.setDomainItemId(app.id().get());
                record.setRowKind(rowAxis.domainItem().kind().name());
                record.setRowId(rowAxis.domainItem().id());
                record.setColumnKind(columnAxis.domainItem().kind().name());
                record.setColumnId(columnAxis.domainItem().id());
                record.setLastUpdatedAt(DateTimeUtilities.nowUtcTimestamp());
                record.setLastUpdatedBy(r.providedBy());
                record.setDescription(r.description());
                return record;
            })
            .collect(toList());
}
 
Example #26
Source File: FinosLicenceComplianceImporter.java    From waltz with Apache License 2.0 4 votes vote down vote up
private void importData(String path) throws IOException, URISyntaxException {
    EntityNamedNoteTypeRecord conditionsNoteType = createEntityNoteDefinitionIfNotExists(
            ENTITY_NOTE_CONDITIONS_NAME,
            ENTITY_NOTE_CONDITIONS_DESC);

    EntityNamedNoteTypeRecord terminationsNoteType = createEntityNoteDefinitionIfNotExists(
            ENTITY_NOTE_TERMINATIONS_NAME,
            ENTITY_NOTE_TERMINATIONS_DESC);

    EntityNamedNoteTypeRecord versioningNoteType = createEntityNoteDefinitionIfNotExists(
            ENTITY_NOTE_VERSIONING_NAME,
            ENTITY_NOTE_VERSIONING_DESC);

    EntityNamedNoteTypeRecord otherNoteType = createEntityNoteDefinitionIfNotExists(
            ENTITY_NOTE_OTHER_NAME,
            ENTITY_NOTE_OTHER_DESC);

    deleteExisting();

    List<LicenceCompliance> compliances = parseData(path);

    System.out.printf("Parsed %s licence compliance files \n", compliances.size());

    Map<String, Licence> licencesByExternalId = licenceDao.findAll()
            .stream()
            .filter(l -> l.externalId().isPresent())
            .collect(toMap(l -> l.externalId().get(), l -> l));

    List<EntityNamedNoteRecord> notes = compliances.stream()
            .flatMap(c -> {
                return Stream.of(c.licenseId())
                        .map(id -> Tuple.tuple(id, c));

            })
            .flatMap(t -> {
                Map<ComplianceType, List<ComplianceTerm>> termsByType = Arrays.stream(t.v2.terms())
                        .collect(groupingBy(term -> term.type()));
                return Stream.of(
                        maybeMkConditionNamedNote(
                                termsByType.get(ComplianceType.CONDITION),
                                licencesByExternalId.get(t.v1),
                                conditionsNoteType),
                        maybeMkBulletNamedNote(
                                termsByType.get(ComplianceType.TERMINATION),
                                licencesByExternalId.get(t.v1),
                                terminationsNoteType),
                        maybeMkBulletNamedNote(
                                termsByType.get(ComplianceType.LICENSE_VERSIONS),
                                licencesByExternalId.get(t.v1),
                                versioningNoteType),
                        maybeMkOtherNamedNote(
                                termsByType.get(ComplianceType.OTHER),
                                licencesByExternalId.get(t.v1),
                                otherNoteType)
                );

            })
            .filter(o -> o.isPresent())
            .map(o -> o.get())
            .collect(toList());

    int[] noteStoreExecute = dsl.batchStore(notes).execute();

    System.out.println("Entity Note records stored: " + noteStoreExecute.length);

}
 
Example #27
Source File: LogicalFlowGenerator.java    From waltz with Apache License 2.0 4 votes vote down vote up
@Override
public Map<String, Integer> create(ApplicationContext ctx) {
    AuthoritativeSourceDao authSourceDao = ctx.getBean(AuthoritativeSourceDao.class);
    ApplicationService applicationDao = ctx.getBean(ApplicationService.class);
    OrganisationalUnitService orgUnitDao = ctx.getBean(OrganisationalUnitService.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);

    List<AuthoritativeSource> authSources = authSourceDao.findByEntityKind(EntityKind.ORG_UNIT);
    List<Application> apps = applicationDao.findAll();
    List<OrganisationalUnit> orgUnits = orgUnitDao.findAll();

    LocalDateTime now = LocalDateTime.now();

    Set<LogicalFlow> expectedFlows = authSources.stream()
            .flatMap(a -> {
                long orgUnitId = a.parentReference().id();

                return randomlySizedIntStream(0, 40)
                        .mapToObj(i ->
                                randomAppPick(apps, orgUnitId)
                                    .map(target -> ImmutableLogicalFlow.builder()
                                            .source(a.applicationReference())
                                            .target(target)
                                            .lastUpdatedBy("admin")
                                            .provenance(SAMPLE_DATA_PROVENANCE)
                                            .lastUpdatedAt(now)
                                            .build())
                                    .orElse(null));
            })
            .filter(Objects::nonNull)
            .collect(toSet());


    Set<LogicalFlow> probableFlows = authSources.stream()
            .flatMap(a -> randomlySizedIntStream(0, 30)
                    .mapToObj(i -> randomAppPick(apps, randomPick(orgUnits).id().get())
                            .map(target -> ImmutableLogicalFlow.builder()
                                    .source(a.applicationReference())
                                    .target(target)
                                    .lastUpdatedBy("admin")
                                    .provenance(SAMPLE_DATA_PROVENANCE)
                                    .lastUpdatedAt(now)
                                    .build())
                            .orElse(null)))
            .filter(Objects::nonNull)
            .collect(toSet());


    Set<LogicalFlow> randomFlows = apps.stream()
            .flatMap(a -> randomlySizedIntStream(0, 5)
                    .mapToObj(i ->
                        randomAppPick(apps, randomPick(orgUnits).id().get())
                                .map(target -> ImmutableLogicalFlow.builder()
                                    .source(a.entityReference())
                                    .target(target)
                                    .lastUpdatedBy("admin")
                                    .provenance(SAMPLE_DATA_PROVENANCE)
                                    .lastUpdatedAt(now)
                                    .build())
                                .orElse(null)))
            .filter(Objects::nonNull)
            .collect(toSet());


    Set<LogicalFlow> all = new HashSet<>();
    all.addAll(randomFlows);
    all.addAll(expectedFlows);
    all.addAll(probableFlows);

    Set<LogicalFlow> deduped = uniqBy(
            all,
            x -> Tuple.tuple(x.source(), x.target()));

    log("--- saving: " + deduped.size());

    Set<LogicalFlowRecord> records = SetUtilities.map(deduped, df -> LogicalFlowDao.TO_RECORD_MAPPER.apply(df, dsl));
    dsl.batchStore(records).execute();

    log("--- done");

    return null;

}
 
Example #28
Source File: FlowSummaryExport.java    From waltz with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) throws IOException {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);

    LogicalFlow logFlow = LogicalFlow.LOGICAL_FLOW.as("logFlow");
    PhysicalFlow physFlow = PhysicalFlow.PHYSICAL_FLOW.as("physFlow");
    AuthoritativeSource auth = AuthoritativeSource.AUTHORITATIVE_SOURCE.as("auth");
    Application src = Application.APPLICATION.as("src");
    Application trg = Application.APPLICATION.as("trg");
    DataType dt = DataType.DATA_TYPE.as("dt");
    LogicalFlowDecorator dec = LogicalFlowDecorator.LOGICAL_FLOW_DECORATOR.as("dec");

    Set<Long> logicalFlowsWithOLAs = getLogicalFlowsWithOLAs(dsl, logFlow, physFlow);
    Set<Long> logicalFlowsWithLDEs = getLogicalFlowsWithLDEs(dsl, logFlow, physFlow);

    FileWriter fw = new FileWriter("c:\\temp\\out.tsv");

    Consumer<Tuple> dumper = Unchecked.consumer(t -> {
        t.forEach(Unchecked.consumer(v -> {
            fw.write(v.toString());
            fw.write("\t");
        }));
        fw.write("\n");
    });

    fw.write("Source\tSource code\tTarget\tTarget code\tData Type\tData Type Code\tAuthoritative\tLDE\tOLA\n");

    dsl.select(src.NAME,
                src.ASSET_CODE,
                trg.NAME,
                trg.ASSET_CODE,
                dt.NAME,
                dt.CODE,
                dec.RATING,
                logFlow.ID)
            .from(logFlow)
            .innerJoin(dec)
                .on(dec.LOGICAL_FLOW_ID.eq(logFlow.ID))
            .innerJoin(dt)
                .on(dt.ID.eq(dec.DECORATOR_ENTITY_ID))
            .innerJoin(src)
                .on(logFlow.SOURCE_ENTITY_ID.eq(src.ID))
            .innerJoin(trg)
                .on(logFlow.TARGET_ENTITY_ID.eq(trg.ID))
            .where(logFlow.ENTITY_LIFECYCLE_STATUS.ne(REMOVED.name())
                .and(src.IS_REMOVED.isFalse())
                .and(trg.IS_REMOVED.isFalse()))
            .fetch()
            .stream()
            .map(r -> {
                Long logicalFlowId = r.get(logFlow.ID);
                return Tuple.tuple(
                        r.get(src.NAME),
                        r.get(src.ASSET_CODE),
                        r.get(trg.NAME),
                        r.get(trg.ASSET_CODE),
                        r.get(dt.NAME),
                        r.get(dt.CODE),
                        authRatingToStr(r.get(dec.RATING)),
                        logicalFlowsWithLDEs.contains(logicalFlowId) ? 1 : 0,
                        logicalFlowsWithOLAs.contains(logicalFlowId) ? 1 : 0);
            })
            .forEach(dumper);

    fw.close();
}
 
Example #29
Source File: FlowSummaryWithTypesAndPhysicalsExport.java    From waltz with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) throws IOException {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    ApplicationIdSelectorFactory appIdSelectorFactory = new ApplicationIdSelectorFactory();
    ApplicationDao applicationDao = ctx.getBean(ApplicationDao.class);
    OrganisationalUnitDao organisationalUnitDao = ctx.getBean(OrganisationalUnitDao.class);
    LogicalFlowDao logicalFlowDao = ctx.getBean(LogicalFlowDao.class);
    LogicalFlowDecoratorDao decoratorDao = ctx.getBean(LogicalFlowDecoratorDao.class);
    DataTypeDao dataTypeDao = ctx.getBean(DataTypeDao.class);

    Select<Record1<Long>> appSelector = mkAppIdSelector(appIdSelectorFactory);
    Select<Record1<Long>> logicalFlowSelector = mkLogicalFlowSelectorFromAppSelector(appSelector);

    System.out.println("Loading apps");
    Set<Application> allApps = fromCollection(applicationDao.findAll());
    System.out.println("Loading in scope apps");
    Set<Long> inScopeAppIds = toIds(applicationDao.findByAppIdSelector(appSelector));
    System.out.println("Loading OUs");
    List<OrganisationalUnit> allOUs = organisationalUnitDao.findAll();
    System.out.println("Loading DTs");
    List<DataType> allDataTypes = dataTypeDao.findAll();

    System.out.println("Loading Logical Flows");
    List<LogicalFlow> logicalFlows = logicalFlowDao.findBySelector(logicalFlowSelector);
    System.out.println("Loading decorators");
    List<DataTypeDecorator> decorators = decoratorDao.findByAppIdSelector(appSelector);
    System.out.println("Loading phys flows");
    Map<Long, Collection<Tuple7<Long, String, String, String, String, String, String>>> physicalsByLogical = loadPhysicalsByLogical(dsl, logicalFlowSelector);

    System.out.println("Indexing");
    Map<Optional<Long>, Application> appsById = indexByOptId(allApps);
    Map<Optional<Long>, DataType> dataTypesById = indexByOptId(allDataTypes);
    Map<Optional<Long>, OrganisationalUnit> ousById = indexByOptId(allOUs);

    Map<Long, Collection<DataTypeDecorator>> decoratorsByLogicalFlowId = groupBy(DataTypeDecorator::dataFlowId, decorators);

    System.out.println("Processing");
    CsvListWriter csvWriter = setupCSVWriter();

    logicalFlows
            .stream()
            .filter(lf -> lf.source().kind() == EntityKind.APPLICATION && lf.target().kind() == EntityKind.APPLICATION)
            .map(Tuple::tuple)
            .map(t -> t.concat(appsById.get(Optional.of(t.v1.source().id()))))
            .map(t -> t.concat(appsById.get(Optional.of(t.v1.target().id()))))
            .filter(t -> t.v2 != null && t.v3 != null)
            .map(t -> t.concat(ousById.get(Optional.of(t.v2.organisationalUnitId()))))
            .map(t -> t.concat(ousById.get(Optional.of(t.v3.organisationalUnitId()))))
            .map(t -> t.concat(decoratorsByLogicalFlowId
                    .getOrDefault(
                            t.v1.id().orElse(-1L),
                            emptyList())
                    .stream()
                    .filter(d -> d.decoratorEntity().kind() == EntityKind.DATA_TYPE)
                    .map(d -> dataTypesById.get(Optional.of(d.decoratorEntity().id())))
                    .sorted(Comparator.comparing(NameProvider::name))
                    .collect(Collectors.toList())))
            .map(t -> t.concat(inScopeAppIds.contains(t.v2.id().get())))
            .map(t -> t.concat(inScopeAppIds.contains(t.v3.id().get())))
            // (lf:1, src:2, trg:3, srcOu:4, trgOU:5, dataType[]:6, srcInScope: 7, trgInScope: 8)
            .flatMap(t -> physicalsByLogical
                        .getOrDefault(
                                t.v1.id().orElse(-1L),
                                newArrayList(tuple(-1L, "-", "-", "-", "-", "-", "-")))
                        .stream()
                        .map(p -> t.concat(p.skip1())))
            .map(t -> newArrayList(
                    t.v2.name(),  // src
                    t.v2.assetCode().orElse(""),
                    t.v2.applicationKind().name(),
                    t.v2.entityLifecycleStatus().name(),
                    Optional.ofNullable(t.v4).map(NameProvider::name).orElse("?"), // src OU
                    t.v7.toString(),
                    t.v3.name(),  // trg
                    t.v3.assetCode().orElse(""),
                    t.v3.applicationKind().name(),
                    t.v3.entityLifecycleStatus().name(),
                    Optional.ofNullable(t.v5).map(NameProvider::name).orElse("?"), // trg OU
                    t.v8.toString(),
                    StringUtilities.joinUsing(t.v6, NameProvider::name, ","),
                    t.v9,
                    t.v10,
                    t.v11,
                    t.v12,
                    t.v13,
                    t.v14))
            .forEach(Unchecked.consumer(csvWriter::write));
}
 
Example #30
Source File: Tuple2id.java    From RankSys with Mozilla Public License 2.0 2 votes vote down vote up
/**
 * Converts the tuple into a jOOL tuple.
 *
 * @return jOOL tuple
 */
public Tuple2<Integer, Double> asTuple() {
    return Tuple.tuple(v1, v2);
}