private void ReplacePathwayComponentRelationships(int componentNbr, Guid parentComponentUid, List <Guid> input, Pathway pathway, int pathwayComponentRelationship, string property, ref SaveStatus status) { var pclist = new List <PathwayComponent>(); foreach (var pcGuid in input) { //look up component var pc = PathwayComponentManager.Get(pcGuid, PathwayComponentManager.componentActionOfNone); if (pc != null && pc.Id > 0) { pclist.Add(pc); } else { //??? status.AddError(string.Format("Component: {0}. Error unable to find PathwayComponent for relationship: {1} using pvGUID: {1}.", componentNbr, pathwayComponentRelationship, pcGuid)); } } //do replace if (!epcmgr.Replace(parentComponentUid, pathwayComponentRelationship, pclist, ref status)) { //nothing more to report? //status.AddError( string.Format( "Component: {0}, Issue encountered replacing {1} component relationships.", componentNbr, property )); } }
private int HandleComponentCondition(PathwayComponentCondition input, Pathway pathway, PathwayComponent component, ref SaveStatus status) { int newId = 0; List <string> messages = new List <string>(); string statusMessage = ""; input.ParentComponentId = component.Id; if (pccm.Save(input, ref messages)) { newId = input.Id; activityMgr.SiteActivityAdd(new SiteActivity() { ActivityType = "PathwayComponent", Activity = "Import", Event = "Add", Comment = string.Format("Added PathwayComponentCondition via Import: '{0}' for Component: '{1}'", input.Name, component.Name), ActivityObjectId = newId, }); } else { status.AddErrorRange(messages); } if (newId == 0 || (!string.IsNullOrWhiteSpace(statusMessage) && statusMessage != "successful")) { status.AddError(string.Format("Row: Issue encountered updating pathway ComponentCondition: {0} for Component: '{1}': {2}", input.Name, component.Name, statusMessage)); return(0); } //================================================== //handle target components - better organization to move this to HandleComponentCondition since all components should now exist List <PathwayComponent> profiles = new List <PathwayComponent>(); messages = new List <string>(); foreach (var tc in input.HasTargetComponentList) { var targetComponent = PathwayComponentManager.Get(tc); if (targetComponent == null || targetComponent.Id == 0) { //shouldn't happen here - although the add attempt could have failed? status.AddError(string.Format("The target pathway component: {0} for ConditionComponent: {1} was not found. This could have been due the an issue adding the component - which should have resulted in an earlier error message.", tc, input.Name)); continue; } profiles.Add(targetComponent); } //now replace relationships if (!epcmgr.Replace(input.RowId, PathwayComponent.PathwayComponentRelationship_TargetComponent, profiles, ref status)) { //status.AddErrorRange( messages ); } return(newId); }
public static TopLevelObject GetEntityAsTopLevelObject(Guid uid) { TopLevelObject tlo = new TopLevelObject(); var entity = EntityManager.GetEntity(uid, false); if (entity == null || entity.Id == 0) { return(null); } // if (entity.EntityTypeId == CodesManager.ENTITY_TYPE_CREDENTIAL) { //actually should return some type info tlo = CredentialManager.GetBasic(entity.EntityBaseId); tlo.EntityTypeId = entity.EntityTypeId; } else if (entity.EntityTypeId == CodesManager.ENTITY_TYPE_ORGANIZATION) { tlo = OrganizationManager.GetBasics(entity.EntityUid); tlo.EntityTypeId = entity.EntityTypeId; } else if (entity.EntityTypeId == CodesManager.ENTITY_TYPE_ASSESSMENT_PROFILE) { tlo = AssessmentManager.GetBasic(entity.EntityBaseId); tlo.EntityTypeId = entity.EntityTypeId; } else if (entity.EntityTypeId == CodesManager.ENTITY_TYPE_LEARNING_OPP_PROFILE) { tlo = LearningOpportunityManager.GetBasic(entity.EntityBaseId); tlo.EntityTypeId = entity.EntityTypeId; } else if (entity.EntityTypeId == CodesManager.ENTITY_TYPE_PATHWAY) { tlo = PathwayManager.GetBasic(entity.EntityBaseId); tlo.EntityTypeId = entity.EntityTypeId; } else if (entity.EntityTypeId == CodesManager.ENTITY_TYPE_PATHWAY_COMPONENT) { tlo = PathwayComponentManager.Get(entity.EntityBaseId); tlo.EntityTypeId = entity.EntityTypeId; } else if (entity.EntityTypeId == CodesManager.ENTITY_TYPE_PATHWAY_SET) { tlo = PathwaySetManager.Get(entity.EntityBaseId); tlo.EntityTypeId = entity.EntityTypeId; } else if (entity.EntityTypeId == CodesManager.ENTITY_TYPE_TRANSFER_VALUE_PROFILE) { tlo = TransferValueProfileManager.Get(entity.EntityBaseId); tlo.EntityTypeId = entity.EntityTypeId; } return(tlo); }
private void ReplacePathwayToPathwayComponentRelationships(List <Guid> input, Pathway pathway, int pathwayComponentRelationship, string property, ref SaveStatus status) { var pclist = new List <PathwayComponent>(); foreach (var pcGuid in input) { //look up component var pc = PathwayComponentManager.Get(pcGuid, PathwayComponentManager.componentActionOfNone); if (pc != null && pc.Id > 0) { pclist.Add(pc); } else { //??? status.AddError(string.Format("ReplacePathwayToPathwayComponentRelationships. Error unable to find record for Pathway.Component using Guid: {0}, for relationship: {1}.", pcGuid, pathwayComponentRelationship)); } } //do replace if (!epcmgr.Replace(pathway.RowId, pathwayComponentRelationship, pclist, ref status)) { //status.AddErrorRange( string.Format( "Row: {0}, Issue encountered replacing {1} component relationships.", currentRowNbr, property ), messages ); } }
public static PathwayComponent GetComponentBasic(int id) { PathwayComponent entity = PathwayComponentManager.Get(id); return(entity); }