Search in sources :

Example 1 with EntityRelationship

use of org.finos.waltz.model.entity_relationship.EntityRelationship in project waltz by khartec.

the class EntityRelationshipHarness method main.

public static void main(String[] args) {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    EntityRelationshipDao dao = ctx.getBean(EntityRelationshipDao.class);
    EntityReference ref = EntityReference.mkRef(EntityKind.MEASURABLE, 613);
    Collection<EntityRelationship> rels = dao.findRelationshipsInvolving(ref);
    rels.forEach(r -> System.out.println(r.a().name()));
    System.out.println("----");
    System.out.println(dao.tallyRelationshipsInvolving(ref));
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) EntityRelationshipDao(org.finos.waltz.data.entity_relationship.EntityRelationshipDao) EntityReference(org.finos.waltz.model.EntityReference) EntityRelationship(org.finos.waltz.model.entity_relationship.EntityRelationship) DSLContext(org.jooq.DSLContext)

Example 2 with EntityRelationship

use of org.finos.waltz.model.entity_relationship.EntityRelationship in project waltz by khartec.

the class RoadmapService method createRoadmap.

public Long createRoadmap(RoadmapCreateCommand command, String userId) {
    long roadmapId = roadmapDao.createRoadmap(command.name(), command.ratingSchemeId(), command.columnType(), command.rowType(), userId);
    if (roadmapId > 0) {
        changeLogService.write(ImmutableChangeLog.copyOf(RoadmapUtilities.mkBasicLogEntry(roadmapId, String.format("Created roadmap: %s", command.name()), userId)).withOperation(Operation.ADD));
    }
    EntityRelationship reln = ImmutableEntityRelationship.builder().a(command.linkedEntity()).b(mkRef(EntityKind.ROADMAP, roadmapId)).relationship(RelationshipKind.RELATES_TO.name()).lastUpdatedBy(userId).build();
    entityRelationshipDao.create(reln);
    return roadmapId;
}
Also used : EntityRelationship(org.finos.waltz.model.entity_relationship.EntityRelationship) ImmutableEntityRelationship(org.finos.waltz.model.entity_relationship.ImmutableEntityRelationship)

Example 3 with EntityRelationship

use of org.finos.waltz.model.entity_relationship.EntityRelationship in project waltz by khartec.

the class MeasurableRelationshipService method create.

public boolean create(String userName, EntityReference entityRefA, EntityReference entityRefB, String relationshipKind, String description) {
    EntityRelationship relationship = ImmutableEntityRelationship.builder().a(entityRefA).b(entityRefB).relationship(relationshipKind).description(description).lastUpdatedBy(userName).build();
    boolean result = entityRelationshipDao.create(relationship);
    if (result) {
        logAddition(relationship);
    }
    return result;
}
Also used : EntityRelationship(org.finos.waltz.model.entity_relationship.EntityRelationship) ImmutableEntityRelationship(org.finos.waltz.model.entity_relationship.ImmutableEntityRelationship)

Example 4 with EntityRelationship

use of org.finos.waltz.model.entity_relationship.EntityRelationship in project waltz by khartec.

the class AppGroupService method addChangeInitiative.

public Collection<ChangeInitiative> addChangeInitiative(String username, long groupId, long changeInitiativeId) throws InsufficientPrivelegeException {
    verifyUserCanUpdateGroup(username, groupId);
    EntityRelationship entityRelationship = buildChangeInitiativeRelationship(username, groupId, changeInitiativeId);
    entityRelationshipDao.save(entityRelationship);
    audit(groupId, username, format("Associated change initiative: %d", changeInitiativeId), EntityKind.CHANGE_INITIATIVE, Operation.ADD);
    return changeInitiativeService.findForSelector(mkOpts(mkRef(EntityKind.APP_GROUP, groupId), HierarchyQueryScope.EXACT));
}
Also used : EntityRelationship(org.finos.waltz.model.entity_relationship.EntityRelationship) ImmutableEntityRelationship(org.finos.waltz.model.entity_relationship.ImmutableEntityRelationship)

Example 5 with EntityRelationship

use of org.finos.waltz.model.entity_relationship.EntityRelationship in project waltz by khartec.

the class AppGroupService method removeChangeInitiative.

public Collection<ChangeInitiative> removeChangeInitiative(String username, long groupId, long changeInitiativeId) throws InsufficientPrivelegeException {
    verifyUserCanUpdateGroup(username, groupId);
    EntityRelationship entityRelationship = buildChangeInitiativeRelationship(username, groupId, changeInitiativeId);
    entityRelationshipDao.remove(entityRelationship.toKey());
    audit(groupId, username, format("Removed associated change initiative: %d", changeInitiativeId), EntityKind.CHANGE_INITIATIVE, Operation.REMOVE);
    return changeInitiativeService.findForSelector(mkOpts(mkRef(EntityKind.APP_GROUP, groupId), HierarchyQueryScope.EXACT));
}
Also used : EntityRelationship(org.finos.waltz.model.entity_relationship.EntityRelationship) ImmutableEntityRelationship(org.finos.waltz.model.entity_relationship.ImmutableEntityRelationship)

Aggregations

EntityRelationship (org.finos.waltz.model.entity_relationship.EntityRelationship)5 ImmutableEntityRelationship (org.finos.waltz.model.entity_relationship.ImmutableEntityRelationship)4 EntityRelationshipDao (org.finos.waltz.data.entity_relationship.EntityRelationshipDao)1 EntityReference (org.finos.waltz.model.EntityReference)1 DSLContext (org.jooq.DSLContext)1 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)1