Пример #1
0
        public static ConceptScheme Get(int id)
        {
            ConceptScheme entity = new ConceptScheme();

            entity = Manager.Get(id);
            return(entity);
        }
Пример #2
0
        public static ConceptScheme GetByCtid(string ctid)
        {
            ConceptScheme entity = new ConceptScheme();

            entity = Manager.GetByCtid(ctid);
            return(entity);
        }
Пример #3
0
        //
        public static List <ConceptSchemeSummary> Search(MainSearchInput data, ref int totalRows)
        {
            string where = "";
            List <string> messages     = new List <string>();
            List <string> competencies = new List <string>();

            //int userId = 0;
            //AppUser user = AccountServices.GetCurrentUser();
            //if ( user != null && user.Id > 0 )
            //	userId = user.Id;
            //only target records with a ctid
            where = " (len(Isnull(base.Ctid,'')) = 39) ";

            SetKeywordFilter(data.Keywords, false, ref where);
            //SearchServices.SetLanguageFilter( data, CodesManager.ENTITY_TYPE_CONCEPT_SCHEME, ref where );

            ////
            //SearchServices.SetAuthorizationFilter( user, "ConceptScheme_Summary", ref where );

            //SearchServices.HandleCustomFilters( data, 60, ref where );
            //

            //can this be replaced by following
            SearchServices.SetRolesFilter(data, ref where);

            //owned/offered
            //SearchServices.SetOrgRolesFilter( data, 3, ref where );
            //probably N/A
            SearchServices.SetBoundariesFilter(data, ref where);

            LoggingHelper.DoTrace(5, "ConceptSchemeServices.Search(). Filter: " + where);

            return(Manager.Search(where, data.SortOrder, data.StartPage, data.PageSize, ref totalRows));
        }
Пример #4
0
        public bool Import(ThisEntity entity, ref SaveStatus status)
        {
            LoggingHelper.DoTrace(5, thisClassName + "Import entered. " + entity.Name);
            //do a get, and add to cache before updating
            if (entity.Id > 0)
            {
                //note could cause problems verifying after an import (i.e. shows cached version. Maybe remove from cache after completion.
                //var detail = GetDetail( entity.Id );
            }
            bool          isValid  = new Manager().Save(entity, ref status, true);
            List <string> messages = new List <string>();

            if (entity.Id > 0)
            {
                if (UtilityManager.GetAppKeyValue("delayingAllCacheUpdates", false) == false)
                {
                    //update cache - not applicable yet
                    //new CacheManager().PopulateEntityRelatedCaches( entity.RowId );
                    //update Elastic
                    if (Utilities.UtilityManager.GetAppKeyValue("updatingElasticIndexImmediately", false))
                    {
                        ElasticHelper.CompetencyFramework_UpdateIndex(entity.Id);
                    }
                    else
                    {
                        new SearchPendingReindexManager().Add(CodesManager.ENTITY_TYPE_CONCEPT_SCHEME, entity.Id, 1, ref messages);
                        if (messages.Count > 0)
                        {
                            status.AddWarningRange(messages);
                        }
                    }
                    new SearchPendingReindexManager().Add(CodesManager.ENTITY_TYPE_ORGANIZATION, entity.OrganizationId, 1, ref messages);
                }
                else
                {
                    new SearchPendingReindexManager().Add(CodesManager.ENTITY_TYPE_CONCEPT_SCHEME, entity.Id, 1, ref messages);
                    new SearchPendingReindexManager().Add(CodesManager.ENTITY_TYPE_ORGANIZATION, entity.OrganizationId, 1, ref messages);
                    if (messages.Count > 0)
                    {
                        status.AddWarningRange(messages);
                    }
                }
                //no caching needed yet
                //CacheManager.RemoveItemFromCache( "cframework", entity.Id );
            }

            return(isValid);
        }
        //


        /// <summary>
        ///
        /// </summary>
        /// <param name="from"></param>
        /// <param name="to"></param>
        /// <param name="childComponentsAction">0-none; 1-summary; 2-deep </param>
        public static void MapFromDB(DBEntity input, ThisEntity output, int childComponentsAction = 1)
        {
            output.Id            = input.Id;
            output.RowId         = input.RowId;
            output.EntityStateId = input.EntityStateId < 1 ? 1 : input.EntityStateId;
            output.CTID          = input.CTID;
            output.Name          = input.Name;
            output.Description   = input.Description;
            output.PathwayCTID   = input.PathwayCTID;
            //if ( input.Entity_HasPathwayComponent != null && input.Entity_HasPathwayComponent.Count > 0 )
            //{
            //	//
            //}

            var relatedEntity = EntityManager.GetEntity(output.RowId, false);

            if (relatedEntity != null && relatedEntity.Id > 0)
            {
                output.EntityLastUpdated = relatedEntity.LastUpdated;
            }

            //need output get parent pathway?
            //output.IsDestinationComponentOf = Entity_PathwayComponentManager.GetPathwayForComponent( output.Id, PathwayComponent.PathwayComponentRelationship_HasDestinationComponent );

            //ispartof. Should be single, but using list for flexibility?
            //actually force one, as we are using pathway identifier an external id for a unique lookup
            //may not want output do this every time?
            //output.IsPartOf = Entity_PathwayComponentManager.GetPathwayForComponent( output.Id, PathwayComponent.PathwayComponentRelationship_HasPart );

            //may want output get all and split out
            if (childComponentsAction == 2)
            {
                output.AllComponents = Entity_PathwayComponentManager.GetAll(output.RowId, componentActionOfSummary);
                foreach (var item in output.AllComponents)
                {
                    if (item.ComponentRelationshipTypeId == PC.PathwayComponentRelationship_HasChild)
                    {
                        output.HasChild.Add(item);
                    }
                    else if (item.ComponentRelationshipTypeId == PC.PathwayComponentRelationship_IsChildOf)
                    {
                        output.IsChildOf.Add(item);
                    }
                    else if (item.ComponentRelationshipTypeId == PC.PathwayComponentRelationship_Preceeds)
                    {
                        output.Preceeds.Add(item);
                    }
                    else if (item.ComponentRelationshipTypeId == PC.PathwayComponentRelationship_Prerequiste)
                    {
                        output.Prerequisite.Add(item);
                    }
                }
                //child components - details of condition, but summary of components
                output.HasCondition = PathwayComponentConditionManager.GetAll(output.Id, true);
            }

            //output.CodedNotation = input.CodedNotation;
            output.ComponentCategory = input.ComponentCategory;
            output.ComponentTypeId   = input.ComponentTypeId;
            if (input.Codes_PathwayComponentType != null && input.Codes_PathwayComponentType.Id > 0)
            {
                output.PathwayComponentType = input.Codes_PathwayComponentType.Title;
            }
            else
            {
                output.PathwayComponentType = GetComponentType(output.ComponentTypeId);
            }
            //will be validated before getting here!
            output.CredentialType = input.CredentialType;
            if (!string.IsNullOrWhiteSpace(output.CredentialType) && output.CredentialType.IndexOf("ctdl/terms") > 0)
            {
                int pos = output.CredentialType.IndexOf("ctdl/terms");
                output.CredentialType = output.CredentialType.Substring(pos + 11);
            }

            //not sure if this will just be a URI, or point output a concept
            //if a concept, would probably need entity.hasConcept
            //output.HasProgressionLevel = input.HasProgressionLevel;
            //if ( !string.IsNullOrWhiteSpace( input.HasProgressionLevel ) )
            //{
            //	output.ProgressionLevel = ConceptSchemeManager.GetByConceptCtid( output.HasProgressionLevel );
            //	output.HasProgressionLevelDisplay = output.ProgressionLevel.PrefLabel;
            //}
            //20-10-28 now storing separated list
            if (!string.IsNullOrWhiteSpace(input.HasProgressionLevel))
            {
                string[] array = input.HasProgressionLevel.Split('|');
                if (array.Count() > 0)
                {
                    foreach (var i in array)
                    {
                        if (!string.IsNullOrWhiteSpace(i))
                        {
                            var pl = ConceptSchemeManager.GetByConceptCtid(i);
                            output.ProgressionLevels.Add(pl);

                            output.HasProgressionLevelDisplay += pl.PrefLabel + ", ";
                        }
                    }
                    output.HasProgressionLevelDisplay.Trim().TrimEnd(',');
                }
            }

            output.ProgramTerm    = input.ProgramTerm;
            output.SubjectWebpage = input.SubjectWebpage;
            output.SourceData     = input.SourceData;

            //where output store ComponentDesignation - textvalue
            //Json
            if (!string.IsNullOrEmpty(input.Properties))
            {
                PathwayComponentProperties pcp = JsonConvert.DeserializeObject <PathwayComponentProperties>(input.Properties);
                if (pcp != null)
                {
                    //unpack ComponentDesignation
                    output.ComponentDesignationList = pcp.ComponentDesignationList;
                    //credit value
                    output.CreditValue = pcp.CreditValue;
                    //this is now QuantitativeValue
                    output.PointValue = pcp.PointValue;

                    output.Identifier = new List <IdentifierValue>();
                    if (pcp.Identifier != null)
                    {
                        output.Identifier = pcp.Identifier;
                    }
                    if (pcp.SourceCredential != null && pcp.SourceCredential.Id > 0)
                    {
                        output.SourceCredential = pcp.SourceCredential;
                        output.SourceData       = "";
                    }
                    if (pcp.SourceAssessment != null && pcp.SourceAssessment.Id > 0)
                    {
                        output.SourceAssessment = pcp.SourceAssessment;
                        output.SourceData       = "";
                    }
                    if (pcp.SourceLearningOpportunity != null && pcp.SourceLearningOpportunity.Id > 0)
                    {
                        output.SourceLearningOpportunity = pcp.SourceLearningOpportunity;
                        output.SourceData = "";
                    }
                }
            }

            //
            if (IsValidDate(input.Created))
            {
                output.Created = ( DateTime )input.Created;
            }
            if (IsValidDate(input.LastUpdated))
            {
                output.LastUpdated = ( DateTime )input.LastUpdated;
            }
        }
Пример #6
0
        public static void MapFromDB_Basic(DBEntity input, ThisEntity output, bool includingComponents)
        {
            output.Id            = input.Id;
            output.RowId         = input.RowId;
            output.EntityStateId = ( int )(input.EntityStateId ?? 1);
            output.Name          = input.Name;
            output.Description   = input.Description == null ? "" : input.Description;
            output.CTID          = input.CTID;
            if (IsGuidValid(input.OwningAgentUid))
            {
                output.OwningAgentUid     = ( Guid )input.OwningAgentUid;
                output.OwningOrganization = OrganizationManager.GetForSummary(output.OwningAgentUid);
                output.OrganizationId     = output.OwningOrganization.Id;
                //get roles
                OrganizationRoleProfile orp = Entity_AgentRelationshipManager.AgentEntityRole_GetAsEnumerationFromCSV(output.RowId, output.OwningAgentUid);
                output.OwnerRoles = orp.AgentRole;
            }
            //
            output.OrganizationRole = Entity_AgentRelationshipManager.AgentEntityRole_GetAll_ToEnumeration(output.RowId, true);
            //
            output.SubjectWebpage = input.SubjectWebpage;
            if (IsValidDate(input.Created))
            {
                output.Created = ( DateTime )input.Created;
            }
            if (IsValidDate(input.LastUpdated))
            {
                output.LastUpdated = ( DateTime )input.LastUpdated;
            }



            if (string.IsNullOrWhiteSpace(output.CTID) || output.EntityStateId < 3)
            {
                output.IsReferenceVersion = true;
                return;
            }
            //=====
            var relatedEntity = EntityManager.GetEntity(output.RowId, false);

            if (relatedEntity != null && relatedEntity.Id > 0)
            {
                output.EntityLastUpdated = relatedEntity.LastUpdated;
            }

            //components
            if (includingComponents)
            {
                //
                output.ProgressionModelURI = input.HasProgressionModel;
                if (!string.IsNullOrWhiteSpace(output.ProgressionModelURI) && includingComponents)
                {
                    //ensure this is not called always from ProgressionModel/CS or will get a stack overflow
                    output.HasProgressionModel = ConceptSchemeManager.GetByCtid(output.ProgressionModelURI);
                }

                //include conditions
                //to.HasPart = PathwayComponentManager.GetAllForPathway( to.CTID, PathwayComponentManager.componentActionOfDeep );
                //actual may be better to do through Entity_PathwayComponent
                //	but only destination component is under pathway
                //will there be an issue with recursion?
                //compare
                //one less that parts???
                //var parts1 = PathwayComponentManager.GetAllForPathway( to.CTID, PathwayComponentManager.componentActionOfDeep );
                //and
                var parts = Entity_PathwayComponentManager.GetAll(output.RowId, PathwayComponentManager.componentActionOfDeep);
                //may want to split out here, do in context

                foreach (var item in parts)
                {
                    if (item.ComponentRelationshipTypeId == PathwayComponent.PathwayComponentRelationship_HasDestinationComponent)
                    {
                        output.HasDestinationComponent.Add(item);
                    }
                    else if (item.ComponentRelationshipTypeId == PathwayComponent.PathwayComponentRelationship_HasChild)
                    {
                        output.HasChild.Add(item);
                    }
                }
                //now get a unique list
                //var parts = to.HasPart;
                output.HasPart = new List <PathwayComponent>();
                foreach (var item in parts)
                {
                    int index = output.HasPart.FindIndex(a => a.CTID == item.CTID);
                    if (index == -1)
                    {
                        output.HasPart.Add(item);
                    }
                }
            }
        }         //