internal void Clone(WorkflowPoolEntity pool, Dictionary <IWorkflowNodeEntity, IWorkflowNodeEntity> nodes) { var oldLane = this.lane.Entity; WorkflowLaneEntity newLane = new WorkflowLaneEntity { Pool = pool, Name = oldLane.Name, BpmnElementId = oldLane.BpmnElementId, Actors = oldLane.Actors.ToMList(), ActorsEval = oldLane.ActorsEval.Clone(), Xml = oldLane.Xml, }.Save(); var newActivities = this.activities.Values.Select(a => a.Entity).ToDictionary(a => a, a => new WorkflowActivityEntity { Lane = newLane, Name = a.Name, BpmnElementId = a.BpmnElementId, Xml = a.Xml, Type = a.Type, ViewName = a.ViewName, RequiresOpen = a.RequiresOpen, Reject = a.Reject, Timeout = a.Timeout, EstimatedDuration = a.EstimatedDuration, Jumps = a.Jumps.Select(j => j.Clone()).ToMList(), Script = a.Script?.Clone(), SubWorkflow = a.SubWorkflow?.Clone(), UserHelp = a.UserHelp, Comments = a.Comments, }); newActivities.Values.SaveList(); nodes.AddRange(newActivities.ToDictionary(kvp => (IWorkflowNodeEntity)kvp.Key, kvp => (IWorkflowNodeEntity)kvp.Value)); var newEvents = this.events.Values.Select(e => e.Entity).ToDictionary(e => e, e => new WorkflowEventEntity { Lane = newLane, Name = e.Name, BpmnElementId = e.BpmnElementId, Type = e.Type, Xml = e.Xml, }); newEvents.Values.SaveList(); nodes.AddRange(newEvents.ToDictionary(kvp => (IWorkflowNodeEntity)kvp.Key, kvp => (IWorkflowNodeEntity)kvp.Value)); var newGateways = this.gateways.Values.Select(g => g.Entity).ToDictionary(g => g, g => new WorkflowGatewayEntity { Lane = newLane, Name = g.Name, BpmnElementId = g.BpmnElementId, Type = g.Type, Direction = g.Direction, Xml = g.Xml, }); newGateways.Values.SaveList(); nodes.AddRange(newGateways.ToDictionary(kvp => (IWorkflowNodeEntity)kvp.Key, kvp => (IWorkflowNodeEntity)kvp.Value)); }
public LaneBuilder(WorkflowLaneEntity l, IEnumerable <WorkflowActivityEntity> activities, IEnumerable <WorkflowEventEntity> events, IEnumerable <WorkflowGatewayEntity> gateways, IEnumerable <XmlEntity <WorkflowConnectionEntity> > connections) { this.lane = new XmlEntity <WorkflowLaneEntity>(l); this.events = events.Select(a => new XmlEntity <WorkflowEventEntity>(a)).ToDictionary(x => x.bpmnElementId); this.activities = activities.Select(a => new XmlEntity <WorkflowActivityEntity>(a)).ToDictionary(x => x.bpmnElementId); this.gateways = gateways.Select(a => new XmlEntity <WorkflowGatewayEntity>(a)).ToDictionary(x => x.bpmnElementId); this.connections = connections.ToDictionary(a => a.bpmnElementId); this.outgoing = this.connections.Values.GroupToDictionary(a => a.Entity.From.ToLite()); this.incoming = this.connections.Values.GroupToDictionary(a => a.Entity.To.ToLite()); }
public static IQueryable <WorkflowActivityEntity> WorkflowActivities(this WorkflowLaneEntity e) { return(LaneActivitiesExpression.Evaluate(e)); }
public static IQueryable <WorkflowEventEntity> WorkflowEvents(this WorkflowLaneEntity e) { return(LaneEventsExpression.Evaluate(e)); }
public static IQueryable <WorkflowGatewayEntity> WorkflowGateways(this WorkflowLaneEntity e) { return(LaneGatewaysExpression.Evaluate(e)); }
public static IQueryable <WorkflowActivityEntity> WorkflowActivities(this WorkflowLaneEntity e) => As.Expression(() => Database.Query <WorkflowActivityEntity>().Where(a => a.Lane.Is(e)));
public static IQueryable <WorkflowEventEntity> WorkflowEvents(this WorkflowLaneEntity e) => As.Expression(() => Database.Query <WorkflowEventEntity>().Where(a => a.Lane == e));
public void ApplyChanges(XElement processElement, Locator locator) { var sequenceFlows = processElement.Elements(bpmn + "sequenceFlow").ToDictionary(a => a.Attribute("id").Value); var oldSequenceFlows = this.sequenceFlows.ToDictionaryEx(a => a.bpmnElementId, "sequenceFlows"); Synchronizer.Synchronize(sequenceFlows, oldSequenceFlows, null, (id, osf) => { this.sequenceFlows.Remove(osf); osf.Entity.Delete(WorkflowConnectionOperation.Delete); }, (id, sf, osf) => { var newFrom = locator.FindEntity(sf.Attribute("sourceRef").Value); var newTo = locator.FindEntity(sf.Attribute("targetRef").Value); if (!newFrom.Is(osf.Entity.From) || !newTo.Is(osf.Entity.To)) { osf.Entity.InDB().UnsafeUpdate() .Set(a => a.From, a => newFrom) .Set(a => a.To, a => newTo) .Execute(); osf.Entity.From = newFrom !; osf.Entity.To = newTo !; osf.Entity.SetCleanModified(false); } }); var oldLanes = this.lanes.Values.ToDictionaryEx(a => a.lane.bpmnElementId, "lanes"); var lanes = processElement.Element(bpmn + "laneSet").Elements(bpmn + "lane").ToDictionaryEx(a => a.Attribute("id").Value); Synchronizer.Synchronize(lanes, oldLanes, createNew: (id, l) => { var wl = new WorkflowLaneEntity { Xml = new WorkflowXmlEmbedded(), Pool = this.pool.Entity }.ApplyXml(l, locator); var lb = new LaneBuilder(wl, Enumerable.Empty <WorkflowActivityEntity>(), Enumerable.Empty <WorkflowEventEntity>(), Enumerable.Empty <WorkflowGatewayEntity>(), Enumerable.Empty <XmlEntity <WorkflowConnectionEntity> >()); lb.ApplyChanges(processElement, l, locator); this.lanes.Add(wl.ToLite(), lb); }, removeOld: null, merge: (id, l, ol) => { var wl = ol.lane.Entity.ApplyXml(l, locator); ol.ApplyChanges(processElement, l, locator); }); Synchronizer.Synchronize(lanes, oldLanes, createNew: null, removeOld: (id, ol) => { ol.ApplyChanges(processElement, ol.lane.Element, locator); this.lanes.Remove(ol.lane.Entity.ToLite()); ol.lane.Entity.Delete(WorkflowLaneOperation.Delete); }, merge: null); Synchronizer.Synchronize(sequenceFlows, oldSequenceFlows, (id, sf) => { var wc = new WorkflowConnectionEntity { Xml = new WorkflowXmlEmbedded() }.ApplyXml(sf, locator); this.sequenceFlows.Add(new XmlEntity <WorkflowConnectionEntity>(wc)); }, null, (id, sf, osf) => { osf.Entity.ApplyXml(sf, locator); }); }
public void ApplyChanges(XElement processElement, Locator locator) { var sequenceFlows = processElement.Elements(bpmn + "sequenceFlow").ToDictionary(a => a.Attribute("id").Value); var oldSequenceFlows = this.sequenceFlows.ToDictionaryEx(a => a.bpmnElementId, "sequenceFlows"); Synchronizer.Synchronize(sequenceFlows, oldSequenceFlows, null, (id, osf) => { this.sequenceFlows.Remove(osf); osf.Entity.Delete(WorkflowConnectionOperation.Delete); }, (id, sf, osf) => { osf.Entity.ApplyXml(sf, locator); }); var oldLanes = this.lanes.Values.ToDictionaryEx(a => a.lane.bpmnElementId, "lanes"); var lanes = processElement.Element(bpmn + "laneSet").Elements(bpmn + "lane").ToDictionaryEx(a => a.Attribute("id").Value); Synchronizer.Synchronize(lanes, oldLanes, (id, l) => { var wl = new WorkflowLaneEntity { Xml = new WorkflowXmlEmbedded(), Pool = this.pool.Entity }.ApplyXml(l, locator); var lb = new LaneBuilder(wl, Enumerable.Empty <WorkflowActivityEntity>(), Enumerable.Empty <WorkflowEventEntity>(), Enumerable.Empty <WorkflowGatewayEntity>(), Enumerable.Empty <XmlEntity <WorkflowConnectionEntity> >()); lb.ApplyChanges(processElement, l, locator); if (lb.IsEmpty()) { wl.Delete(WorkflowLaneOperation.Delete); } else { this.lanes.Add(wl.ToLite(), lb); } }, (id, ol) => { this.lanes.Remove(ol.lane.Entity.ToLite()); ol.DeleteAll(locator); }, (id, l, ol) => { var wl = ol.lane.Entity.ApplyXml(l, locator); ol.ApplyChanges(processElement, l, locator); if (ol.IsEmpty()) { this.lanes.Remove(wl.ToLite()); wl.Delete(WorkflowLaneOperation.Delete); } }); Synchronizer.Synchronize(sequenceFlows, oldSequenceFlows, (id, sf) => { var wc = new WorkflowConnectionEntity { Xml = new WorkflowXmlEmbedded() }.ApplyXml(sf, locator); this.sequenceFlows.Add(new XmlEntity <WorkflowConnectionEntity>(wc)); }, null, (id, sf, osf) => { osf.Entity.ApplyXml(sf, locator); }); }
internal LaneBuilder FindLane(WorkflowLaneEntity lane) { return(this.pools.Values.SelectMany(a => a.GetLanes()).Single(l => l.lane.Entity.Is(lane))); }