コード例 #1
0
        public static ThisEntity GetDetail(int id, bool skippingCache = false)
        {
            ThisEntity entity = EntityMgr.GetDetails(id);


            return(entity);
        }
コード例 #2
0
        public static ThisEntity GetByCtid(string ctid)
        {
            ThisEntity entity = new ThisEntity();

            if (string.IsNullOrWhiteSpace(ctid))
            {
                return(entity);
            }

            return(EntityMgr.GetByCtid(ctid));
        }
コード例 #3
0
        public static ThisEntity GetDetailByCtid(string ctid, bool skippingCache = false)
        {
            ThisEntity entity = new ThisEntity();

            if (string.IsNullOrWhiteSpace(ctid))
            {
                return(entity);
            }
            var record = EntityMgr.GetByCtid(ctid);

            return(GetDetail(record.Id, skippingCache));
        }
コード例 #4
0
        }        //

        /// <summary>
        /// Or just get all and let caller sort the data
        /// </summary>
        /// <param name="parentId"></param>
        /// <returns></returns>
        public static List <ThisEntity> GetAll(int parentId)
        {
            var entity = new ThisEntity();
            var list   = new List <ThisEntity>();

            if (parentId < 1)
            {
                return(list);
            }
            try
            {
                using (var context = new EntityContext())
                {
                    //there could be multiple relationships for a parent and component
                    List <DBEntity> results = context.Entity_HasPathway
                                              .Where(s => s.EntityId == parentId)
                                              .OrderBy(s => s.PathwayRelationshipTypeId)
                                              .ThenBy(s => s.Pathway.Name)     //
                                              .ToList();

                    if (results != null && results.Count > 0)
                    {
                        foreach (var from in results)
                        {
                            if (from != null && from.Id > 0)
                            {
                                entity.Id        = from.Id;
                                entity.EntityId  = from.EntityId;
                                entity.PathwayId = from.PathwayId;
                                entity.PathwayRelationshipTypeId = from.PathwayRelationshipTypeId > 0 ? from.PathwayRelationshipTypeId : 0;
                                if (IsValidDate(from.Created))
                                {
                                    entity.Created = ( DateTime )from.Created;
                                }

                                entity.PathwayName = from.Pathway.Name;
                                //to.Credential = from.Credential;
                                entity.Pathway = new Pathway();
                                PathwayManager.MapFromDB(from.Pathway, entity.Pathway, false);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LoggingHelper.LogError(ex, thisClassName + ".GetAll");
            }
            return(list);
        }        //
コード例 #5
0
        public bool Import(ThisEntity entity, ref SaveStatus status)
        {
            //do a get, and add to cache before updating
            if (entity.Id > 0)
            {
                //need to force caching here
                //var detail = GetDetail( entity.Id );
            }
            bool          isValid  = new EntityMgr().Save(entity, ref status);
            List <string> messages = new List <string>();

            if (entity.Id > 0)
            {
                HandleComponents(entity, ref status);

                CacheManager.RemoveItemFromCache("pathway", entity.Id);

                if (UtilityManager.GetAppKeyValue("delayingAllCacheUpdates", false) == false)
                {
                    //update cache
                    new CacheManager().PopulateEntityRelatedCaches(entity.RowId);
                    //update Elastic
                    if (UtilityManager.GetAppKeyValue("usingElasticPathwaySearch", false))
                    {
                        ElasticHelper.Pathway_UpdateIndex(entity.Id);
                    }
                    else
                    {
                        new SearchPendingReindexManager().Add(8, entity.Id, 1, ref messages);
                        if (messages.Count > 0)
                        {
                            status.AddWarningRange(messages);
                        }
                    }
                }
                else
                {
                    new SearchPendingReindexManager().Add(CodesManager.ENTITY_TYPE_PATHWAY, entity.Id, 1, ref messages);
                    new SearchPendingReindexManager().Add(CodesManager.ENTITY_TYPE_ORGANIZATION, entity.OwningOrganizationId, 1, ref messages);
                    if (messages.Count > 0)
                    {
                        status.AddWarningRange(messages);
                    }
                }
            }

            return(isValid);
        }
コード例 #6
0
        }        //

        public static List <Pathway> GetPathwayForComponent(int pathwayComponentId, int componentRelationshipTypeId)
        {
            /*
             *
             */
            var entity = new Pathway();
            var list   = new List <Pathway>();

            if (pathwayComponentId < 1 || componentRelationshipTypeId < 1)
            {
                return(list);
            }
            try
            {
                using (var context = new EntityContext())
                {
                    //there should be only one pathway-component for the passed relationship - typically ispartof
                    List <DBEntity> results = context.Entity_HasPathwayComponent
                                              .Where(s => s.PathwayComponentId == pathwayComponentId && s.ComponentRelationshipTypeId == componentRelationshipTypeId &&
                                                     s.Entity.EntityTypeId == CodesManager.ENTITY_TYPE_PATHWAY)
                                              .OrderBy(s => s.ComponentRelationshipTypeId)
                                              .ThenBy(s => s.Entity.EntityBaseName)     //
                                              .ToList();

                    if (results != null && results.Count > 0)
                    {
                        foreach (var from in results)
                        {
                            if (from != null && from.Id > 0)
                            {
                                if (from.Entity != null && from.Entity.EntityBaseId != null)
                                {
                                    //is basic enough?
                                    entity = PathwayManager.GetBasic(( int )from.Entity.EntityBaseId);
                                }

                                list.Add(entity);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LoggingHelper.LogError(ex, thisClassName + ".GetPathwayForComponent");
            }
            return(list);
        }        //
コード例 #7
0
        public static List <ThisEntity> GetPathwaysOwnedByOrg(int orgId, int maxRecords)
        {
            string where = "";
            List <string> competencies = new List <string>();
            int           totalRows    = 0;

            //only target full entities
            where = " ( base.EntityStateId = 3 ) ";

            if (orgId > 0)
            {
                where = where + " AND " + string.Format(" ( base.OrganizationId = {0} ) ", orgId);
            }

            LoggingHelper.DoTrace(5, "PathwayServices.GetPathwaysOwnedByOrg(). Filter: " + where);
            return(EntityMgr.Search(where, "", 1, maxRecords, ref totalRows));
        }
コード例 #8
0
        public bool UpdateParts(ThisEntity entity, ref SaveStatus status)
        {
            bool isAllValid = true;
            Entity_AgentRelationshipManager mgr = new Entity_AgentRelationshipManager();
            Entity relatedEntity = EntityManager.GetEntity(entity.RowId);

            if (relatedEntity == null || relatedEntity.Id == 0)
            {
                status.AddError(thisClassName + " - Error - the parent entity was not found.");
                return(false);
            }
            mgr.DeleteAll(relatedEntity, ref status);

            mgr.SaveList(relatedEntity.Id, Entity_AgentRelationshipManager.ROLE_TYPE_OFFERED_BY, entity.OfferedBy, ref status);
            mgr.SaveList(relatedEntity.Id, Entity_AgentRelationshipManager.ROLE_TYPE_OWNER, entity.OwnedBy, ref status);

            var epmgr = new Entity_PathwayManager();
            //handle pathways - using replace
            //actually just use typical pattern of delete all and then add
            //could be extreme
            //epmgr.DeleteAll( parent.EntityUid, ref status );
            var list = new List <int>();

            //check if we should get the list of ids easier
            foreach (var item in entity.HasPathwayList)
            {
                var p = PathwayManager.GetBasic(item);
                if (p != null && p.Id > 0)
                {
                    list.Add(p.Id);
                }
                else
                {
                    //??
                    status.AddError(thisClassName + string.Format(" - Error - the pathway using Guid: {0} entity was not found.", item.ToString()));
                }
            }
            if (!new Entity_PathwayManager().Replace(entity.RowId, 1, list, ref status))
            {
                isAllValid = false;
            }

            return(isAllValid);
        }
コード例 #9
0
        /// <summary>
        /// Get all components for the provided entity
        /// The returned entities are just the base
        /// </summary>
        /// <param name="parentUid"></param>
        /// <returns></returns>
        public static List <Pathway> GetAll(Guid parentUid, bool includingComponents = false)
        {
            List <Pathway> list   = new List <Pathway>();
            Pathway        entity = new Pathway();

            Entity parent = EntityManager.GetEntity(parentUid);

            LoggingHelper.DoTrace(7, string.Format("Entity_Pathway_GetAll: parentUid:{0} entityId:{1}, e.EntityTypeId:{2}", parentUid, parent.Id, parent.EntityTypeId));

            try
            {
                using (var context = new EntityContext())
                {
                    List <DBEntity> results = context.Entity_HasPathway
                                              .Where(s => s.EntityId == parent.Id)
                                              .OrderBy(s => s.Pathway.Name)             //not suire
                                              .ToList();

                    if (results != null && results.Count > 0)
                    {
                        foreach (DBEntity item in results)
                        {
                            //actually the relationship type is not applicable in the component
                            entity = new Pathway()
                            {
                                PathwayRelationshipTypeId = item.PathwayRelationshipTypeId
                            };
                            //not sure if we will have variances in what is returned
                            PathwayManager.MapFromDB(item.Pathway, entity, includingComponents);

                            list.Add(entity);
                        }
                    }
                    return(list);
                }
            }
            catch (Exception ex)
            {
                LoggingHelper.LogError(ex, thisClassName + ".Entity_Pathway_GetAll");
            }
            return(list);
        }
コード例 #10
0
        }        //

        private static List <ThisEntity> DoPathwaySearch(MainSearchInput data, ref int totalRows)
        {
            string where = "";

            //only target full entities
            where = " ( base.EntityStateId = 3 ) ";

            //need to create a new category id for custom filters
            //SearchServices.HandleCustomFilters( data, 61, ref where );

            SetKeywordFilter(data.Keywords, false, ref where);
            SearchServices.SetSubjectsFilter(data, CodesManager.ENTITY_TYPE_PATHWAY, ref where);

            //SetPropertiesFilter( data, ref where );
            SearchServices.SetRolesFilter(data, ref where);
            SearchServices.SetBoundariesFilter(data, ref where);


            LoggingHelper.DoTrace(5, "PathwayServices.Search(). Filter: " + where);
            return(EntityMgr.Search(where, data.SortOrder, data.StartPage, data.PageSize, ref totalRows));
        }
コード例 #11
0
        public static ThisEntity GetBasic(int id)
        {
            ThisEntity entity = EntityMgr.GetBasic(id);

            return(entity);
        }
コード例 #12
0
        public static void MapFromDB(DBEntity from, ThisEntity to, bool includingComponents = true)
        {
            to.Id             = from.Id;
            to.RowId          = from.RowId;
            to.EntityStateId  = from.EntityStateId;
            to.OrganizationId = from.OrgId;
            to.Name           = from.Name;
            to.Description    = from.Description;

            to.IsProgressionModel = from.IsProgressionModel == null ? false : (bool)from.IsProgressionModel;
            to.CTID   = from.CTID.ToLower();
            to.Source = from.Source;

            to.PublicationStatusType = from.PublicationStatusType;
            to.CredentialRegistryId  = from.CredentialRegistryId;
            if (to.OrganizationId > 0)
            {
                to.OwningOrganization = OrganizationManager.GetForSummary(to.OrganizationId);

                to.OwningAgentUid = to.OwningOrganization.RowId;
                //get roles- not sure. Can have own and offer
                //OrganizationRoleProfile orp = Entity_AgentRelationshipManager.AgentEntityRole_GetAsEnumerationFromCSV( to.RowId, to.OwningAgentUid );
                //to.OwnerRoles = orp.AgentRole;
                //if ( to.OwnerRoles.HasItems() == false )
                //{
                //	EnumeratedItem ei = Entity_AgentRelationshipManager.GetAgentRole( "Owned By" );
                //	if ( ei == null || ei.Id == 0 )
                //	{
                //		//messages.Add( string.Format( "The organization role: {0} is not valid", "OwnedBy" ) );
                //	}
                //	else
                //	{
                //		to.OwnerRoles.Items.Add( ei );
                //	}
                //}
            }
            //
            to.OrganizationRole = Entity_AgentRelationshipManager.AgentEntityRole_GetAll_ToEnumeration(to.RowId, true);
            //
            if (from.ConceptScheme_Concept != null && from.ConceptScheme_Concept.Any())
            {
                foreach (var item in from.ConceptScheme_Concept)
                {
                    to.HasConcepts.Add(new Models.Common.Concept()
                    {
                        Id           = item.Id,
                        CTID         = item.CTID,
                        PrefLabel    = item.PrefLabel,
                        Definition   = item.Definition,
                        IsTopConcept = item.IsTopConcept ?? false
                    });
                }
            }
            //
            if (includingComponents)
            {
                //how to know if this is a progression model? Or just do get anyway
                to.Pathways   = PathwayManager.GetAllForProgressionModel(to.CTID);
                to.HasPathway = to.Pathways.Select(m => m.CTID).ToList();
            }
            //
            if (IsValidDate(from.Created))
            {
                to.Created = ( DateTime )from.Created;
            }
            if (IsValidDate(from.LastUpdated))
            {
                to.LastUpdated = ( DateTime )from.LastUpdated;
            }
        }