Search in sources :

Example 21 with Association

use of org.eclipse.bpmn2.Association in project drools by kiegroup.

the class AssociationConverter method assignAttributes.

@Override
protected void assignAttributes(HierarchicalStreamReader reader, Object parent) {
    super.assignAttributes(reader, parent);
    Association a = (Association) parent;
    String associationDirectionValue = reader.getAttribute(ASSOCIATION_DIRECTION);
    if (associationDirectionValue != null)
        a.setAssociationDirection(AssociationDirection.fromValue(associationDirectionValue));
}
Also used : Association(org.kie.dmn.model.v1_1.Association)

Example 22 with Association

use of org.eclipse.bpmn2.Association in project polymap4-core by Polymap4.

the class ProjectNode method findUserSettings.

/**
 */
protected <N extends ProjectNode, U extends UserSettings> U findUserSettings(Class<U> userSettingsType, Association<N> backAssoc) {
    String username = SecurityContext.instance().getUser().getName();
    // give every instance its own UnitOfWork; so modifications can be
    // AutoCommit without interfering with the main UnitOfWork
    EntityRepository repo = context.getRepository();
    UnitOfWork uow = repo.newUnitOfWork();
    U template = Expressions.template(userSettingsType, repo);
    ResultSet<U> rs = uow.query(userSettingsType).where(and(is(backAssoc, (N) ProjectNode.this), eq(template.username, username))).maxResults(2).execute();
    assert rs.size() >= 0 || rs.size() <= 1 : "Illegal result set size: " + rs.size();
    // not found
    if (rs.size() == 0) {
        U result = uow.createEntity(userSettingsType, null, (U proto) -> {
            ProjectNode localNode = uow.entity(ProjectNode.this);
            ((Association) backAssoc.info().get(proto)).set(localNode);
            proto.username.set(username);
            return proto;
        });
        uow.commit();
        return uow.entity(result);
    } else // found
    {
        return rs.stream().findAny().get();
    }
}
Also used : UnitOfWork(org.polymap.model2.runtime.UnitOfWork) Association(org.polymap.model2.Association) EntityRepository(org.polymap.model2.runtime.EntityRepository)

Aggregations

DataInputAssociation (org.eclipse.bpmn2.DataInputAssociation)12 ArrayList (java.util.ArrayList)11 DataOutputAssociation (org.eclipse.bpmn2.DataOutputAssociation)11 List (java.util.List)8 Artifact (org.eclipse.bpmn2.Artifact)7 Association (org.eclipse.bpmn2.Association)7 AdHocSubProcess (org.eclipse.bpmn2.AdHocSubProcess)6 DataInput (org.eclipse.bpmn2.DataInput)6 SubProcess (org.eclipse.bpmn2.SubProcess)6 NormalDistributionType (bpsim.NormalDistributionType)5 Parameter (bpsim.Parameter)5 PoissonDistributionType (bpsim.PoissonDistributionType)5 TimeParameters (bpsim.TimeParameters)5 UniformDistributionType (bpsim.UniformDistributionType)5 Assignment (org.eclipse.bpmn2.Assignment)5 DataOutput (org.eclipse.bpmn2.DataOutput)5 ItemAwareElement (org.eclipse.bpmn2.ItemAwareElement)5 Process (org.eclipse.bpmn2.Process)5 EObject (org.eclipse.emf.ecore.EObject)5 SimpleFeatureMapEntry (org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry)5