private static ThisEntityDetail MapToAPI(ThisEntity input)
        {
            var output = new ThisEntityDetail()
            {
                Meta_Id               = input.Id,
                CTID                  = input.CTID,
                Name                  = input.Name,
                FriendlyName          = HttpUtility.UrlPathEncode(input.Name),
                Description           = input.Description,
                SubjectWebpage        = input.SubjectWebpage,
                EntityTypeId          = 23,
                CredentialRegistryURL = RegistryServices.GetResourceUrl(input.CTID),
                RegistryData          = ServiceHelper.FillRegistryData(input.CTID)
            };

            //TODO - add pathway
            if (input.Pathways != null && input.Pathways.Any())
            {
                output.HasPathways = new List <WMA.Outline>();
                foreach (var target in input.Pathways)
                {
                    if (target != null && !string.IsNullOrWhiteSpace(target.Name))
                    {
                        output.HasPathways.Add(ServiceHelper.MapToOutline(target, searchType));
                    }
                }
                output.HasPathway  = ServiceHelper.MapOutlineToAJAX(output.HasPathways, "Has {0} Pathways(s)");
                output.HasPathways = null;
            }

            return(output);
        }
Ejemplo n.º 2
0
        private static ThisEntityDetail MapToAPI(ThisEntity input)
        {
            var output = new ThisEntityDetail()
            {
                Meta_Id               = input.Id,
                CTID                  = input.CTID,
                Name                  = input.Name,
                FriendlyName          = HttpUtility.UrlPathEncode(input.Name),
                Description           = input.Description,
                SubjectWebpage        = input.SubjectWebpage,
                EntityTypeId          = 8,
                CredentialRegistryURL = RegistryServices.GetResourceUrl(input.CTID),
                RegistryData          = ServiceHelper.FillRegistryData(input.CTID)
            };

            return(output);
        }
Ejemplo n.º 3
0
        private static WMA.CredentialDetail MapToAPI(ThisEntity input)
        {
            var output = new WMA.CredentialDetail()
            {
                Meta_Id               = input.Id,
                CTID                  = input.CTID,
                Name                  = input.Name,
                Description           = input.Description,
                SubjectWebpage        = input.SubjectWebpage,
                EntityTypeId          = 1,
                CTDLTypeLabel         = input.CredentialType,
                CTDLType              = input.CredentialTypeSchema,
                CredentialRegistryURL = RegistryServices.GetResourceUrl(input.CTID),
                RegistryData          = ServiceHelper.FillRegistryData(input.CTID)
            };

            //
            //output.CTDLType = record.CredentialType; ;
            //output.AgentSectorType = ServiceHelper.MapPropertyLabelLinks( org.AgentSectorType, "organization" );
            output.FriendlyName  = HttpUtility.UrlPathEncode(input.Name);
            output.AlternateName = input.AlternateName;

            //owned by and offered by
            //need a label link for header
            if (input.OwningOrganizationId > 0)
            {
                output.OwnedByLabel = ServiceHelper.MapDetailLink("Organization", input.OrganizationName, input.OwningOrganizationId);
            }
            var work = ServiceHelper.MapOrganizationRoleProfileToOutline(input.OrganizationRole, Entity_AgentRelationshipManager.ROLE_TYPE_OWNER);

            output.OwnedBy = ServiceHelper.MapOutlineToAJAX(work, "");
            //
            work             = ServiceHelper.MapOrganizationRoleProfileToOutline(input.OrganizationRole, Entity_AgentRelationshipManager.ROLE_TYPE_OFFERED_BY);
            output.OfferedBy = ServiceHelper.MapOutlineToAJAX(work, "Offered by {0} Organization(s)");
            //

            //QA for owner,not offerer
            if (input.OwningOrganization != null && input.OwningOrganization.Id > 0)
            {
                if (input.OwningOrganization.OrganizationRole_Recipient != null && input.OwningOrganization.OrganizationRole_Recipient.Any())
                {
                    output.OwnerQAReceived = ServiceHelper.MapQAReceived(input.OwningOrganization.OrganizationRole_Recipient, searchType);
                }
                //var inheritedRoles = SetupRoles( roleSet.ActingAgent.OrganizationRole_Recipient, loadedAgentIDs );
                //wrapper.QAFromOwner = inheritedRoles.QADirect;
            }
            //
            output.Meta_LastUpdated = input.EntityLastUpdated;
            output.Meta_StateId     = input.EntityStateId;
            output.EntityTypeId     = input.EntityTypeId;
            if (input.InLanguageCodeList != null && input.InLanguageCodeList.Any())
            {
                //output.Meta_Language = input.InLanguageCodeList[ 0 ].TextTitle;
                output.InLanguage = new List <string>();
                foreach (var item in input.InLanguageCodeList)
                {
                    output.InLanguage.Add(item.TextTitle);
                }
            }
            try
            {
                if (input.HasVerificationType_Badge)
                {
                    output.CTDLTypeLabel += " + Badge Issued";
                }
                output.Image = input.Image;
                //
                if (!string.IsNullOrWhiteSpace(input.AvailabilityListing))
                {
                    output.AvailabilityListing = new List <string>()
                    {
                        input.AvailabilityListing
                    }
                }
                ;
                if (!string.IsNullOrWhiteSpace(input.AvailableOnlineAt))
                {
                    output.AvailableOnlineAt = new List <string>()
                    {
                        input.AvailableOnlineAt
                    }
                }
                ;

                if (input.CopyrightHolderOrganization != null && input.CopyrightHolderOrganization.Any())
                {
                    output.CopyrightHolder = new List <WMA.Outline>();
                    //output.CopyrightHolder2 = new List<WMA.LabelLink>();
                    foreach (var target in input.CopyrightHolderOrganization)
                    {
                        if (target != null && target.Id > 0)
                        {
                            //TODO - add overload to only get minimum data - like Link
                            output.CopyrightHolder.Add(ServiceHelper.MapToOutline(target, "organization"));

                            //var link = ServiceHelper.MapDetailLink( "organization", target.Name, target.Id );
                            //output.CopyrightHolder2.Add( link );
                        }
                    }
                    //or Link objects
                }

                output.CredentialStatusType = ServiceHelper.MapPropertyLabelLink(input.CredentialStatusType, searchType);
                output.CredentialType       = ServiceHelper.MapPropertyLabelLink(input.CredentialTypeEnum, searchType);

                output.DateEffective     = input.DateEffective;
                output.ExpirationDate    = input.ExpirationDate;
                output.EstimatedDuration = ServiceHelper.MapDurationProfiles(input.EstimatedDuration);
                output.RenewalFrequency  = ServiceHelper.MapDurationItem(input.RenewalFrequency);
                //
                if (input.DegreeConcentration != null && input.DegreeConcentration.Any())
                {
                    output.DegreeConcentration = ServiceHelper.MapPropertyLabelLinks(input.DegreeConcentration, searchType);
                }
                if (input.DegreeMajor != null && input.DegreeMajor.Any())
                {
                    output.DegreeMajor = ServiceHelper.MapPropertyLabelLinks(input.DegreeMajor, searchType);
                }
                if (input.DegreeMinor != null && input.DegreeMinor.Any())
                {
                    output.DegreeMinor = ServiceHelper.MapPropertyLabelLinks(input.DegreeMinor, searchType);
                }
                //
                if (input.EmbeddedCredentials != null && input.EmbeddedCredentials.Any())
                {
                    output.HasPart2 = new List <WMA.Outline>();
                    foreach (var target in input.EmbeddedCredentials)
                    {
                        if (target != null && !string.IsNullOrWhiteSpace(target.Name))
                        {
                            output.HasPart2.Add(ServiceHelper.MapToOutline(target, searchType));
                        }
                    }
                    output.HasPart  = ServiceHelper.MapOutlineToAJAX(output.HasPart2, "Includes {0} Credential(s)");
                    output.HasPart2 = null;
                }
                //
                if (input.IsPartOf != null && input.IsPartOf.Any())
                {
                    output.IsPartOf2 = new List <WMA.Outline>();
                    foreach (var target in input.IsPartOf)
                    {
                        if (target != null && !string.IsNullOrWhiteSpace(target.Name))
                        {
                            output.IsPartOf2.Add(ServiceHelper.MapToOutline(target, searchType));
                        }
                    }
                    output.IsPartOf  = ServiceHelper.MapOutlineToAJAX(output.IsPartOf2, "Is Part of {0} Credential(s)");
                    output.IsPartOf2 = null;
                }
            }
            catch (Exception ex)
            {
                LoggingHelper.LogError(ex, string.Format(thisClassName + ".MapToAPI. Section 1, Name: {0}, Id: [1}", input.Name, input.Id));
            }

            //addresses
            //MapAddress( input, ref output );
            output.AvailableAt = ServiceHelper.MapAddress(input.Addresses);

            //
            output.Image = input.Image;
            if (!string.IsNullOrWhiteSpace(input.CredentialTypeSchema))
            {
                output.Meta_Icon = WorkITSearchServices.GetCredentialIcon(input.CredentialTypeSchema.ToLower());
            }
            //
            output.IndustryType             = ServiceHelper.MapReferenceFrameworkLabelLink(input.IndustryType, searchType, CodesManager.PROPERTY_CATEGORY_NAICS);
            output.OccupationType           = ServiceHelper.MapReferenceFrameworkLabelLink(input.OccupationType, searchType, CodesManager.PROPERTY_CATEGORY_SOC);
            output.InstructionalProgramType = ServiceHelper.MapReferenceFrameworkLabelLink(input.InstructionalProgramType, searchType, CodesManager.PROPERTY_CATEGORY_CIP);
            //
            output.IsReferenceVersion = input.IsReferenceVersion;
            //
            if (input.Keyword != null && input.Keyword.Any())
            {
                output.Keyword = ServiceHelper.MapPropertyLabelLinks(input.Keyword, searchType);
            }
            if (input.Subject != null && input.Subject.Any())
            {
                output.Subject = ServiceHelper.MapPropertyLabelLinks(input.Subject, searchType);
            }
            //
            output.AssessmentDeliveryType = ServiceHelper.MapPropertyLabelLinks(input.AssessmentDeliveryType, searchType);
            output.AudienceLevelType      = ServiceHelper.MapPropertyLabelLinks(input.AudienceLevelType, searchType);
            output.AudienceType           = ServiceHelper.MapPropertyLabelLinks(input.AudienceType, searchType);
            output.LearningDeliveryType   = ServiceHelper.MapPropertyLabelLinks(input.LearningDeliveryType, searchType);

            //
            //condition profiles
            try
            {
                output.Corequisite = ServiceHelper.MapToConditionProfiles(input.Corequisite, searchType);
                output.Recommends  = ServiceHelper.MapToConditionProfiles(input.Recommends, searchType);
                output.Renewal     = ServiceHelper.MapToConditionProfiles(input.Renewal, searchType);
                output.Requires    = ServiceHelper.MapToConditionProfiles(input.Requires, searchType);
                if (input.CommonConditions != null && input.CommonConditions.Any())
                {
                    //these will likely just be mapped to specific conditions
                    output.CommonConditions = ServiceHelper.MapConditionManifests(input.CommonConditions, searchType);
                    if (output.CommonConditions != null && output.CommonConditions.Any())
                    {
                        foreach (var item in output.CommonConditions)
                        {
                            if (item.Requires != null && item.Requires.Any())
                            {
                                output.Requires = AppendConditions(item.Requires, output.Requires);
                            }
                            if (item.Recommends != null && item.Recommends.Any())
                            {
                                output.Recommends = AppendConditions(item.Recommends, output.Recommends);
                            }
                            if (item.Corequisite != null && item.Corequisite.Any())
                            {
                                output.Corequisite = AppendConditions(item.Requires, output.Corequisite);
                            }
                            if (item.Renewal != null && item.Renewal.Any())
                            {
                                output.Renewal = AppendConditions(item.Renewal, output.Renewal);
                            }
                        }
                    }
                }
                //connection profiles
                if (input.CredentialConnections != null && input.CredentialConnections.Any())
                {
                    //var list = input.CredentialConnections.Where( s => s.ConditionSubTypeId == 2 && s.ConnectionProfileTypeId == Entity_ConditionProfileManager.ConnectionProfileType_AdvancedStandingFor ).ToList();
                    //foreach ( var item in input.CredentialConnections )
                    //{
                    //	//some default for 1??
                    //	if ( item.ConditionSubTypeId == 2 && item.ConnectionProfileTypeId == Entity_ConditionProfileManager.ConnectionProfileType_AdvancedStandingFor )
                    //		input.IsAdvancedStandingFor.Add( item );
                    //	else if ( item.ConditionSubTypeId == 2 && item.ConnectionProfileTypeId == Entity_ConditionProfileManager.ConnectionProfileType_AdvancedStandingFrom )
                    //		input.AdvancedStandingFrom.Add( item );
                    //	else if ( item.ConditionSubTypeId == 2 && item.ConnectionProfileTypeId == Entity_ConditionProfileManager.ConnectionProfileType_PreparationFor )
                    //		input.IsPreparationFor.Add( item );
                    //	else if ( item.ConditionSubTypeId == 2 && item.ConnectionProfileTypeId == Entity_ConditionProfileManager.ConnectionProfileType_PreparationFrom )
                    //		input.PreparationFrom.Add( item );
                    //	{
                    //		//????;
                    //	}


                    //}
                }
                output.AdvancedStandingFrom  = ServiceHelper.MapToConditionProfiles(input.AdvancedStandingFrom, searchType);
                output.IsAdvancedStandingFor = ServiceHelper.MapToConditionProfiles(input.IsAdvancedStandingFor, searchType);
                //
                output.PreparationFrom  = ServiceHelper.MapToConditionProfiles(input.PreparationFrom, searchType);
                output.IsPreparationFor = ServiceHelper.MapToConditionProfiles(input.IsPreparationFor, searchType);
                //
                output.IsRequiredFor    = ServiceHelper.MapToConditionProfiles(input.IsRequiredFor, searchType);
                output.IsRecommendedFor = ServiceHelper.MapToConditionProfiles(input.IsRecommendedFor, searchType);
            }
            catch (Exception ex)
            {
                LoggingHelper.LogError(ex, string.Format(thisClassName + ".MapToAPI. Section 2, Name: {0}, Id: [1}", input.Name, input.Id));
            }
            //====================================
            //the following can be made a common method
            var dataMergedRequirements    = new MergedConditions();
            var dataMergedRecommendations = new MergedConditions();
            var dataConnections           = new ConnectionData();

            ServiceHelper.GetAllChildren(dataMergedRequirements, dataMergedRecommendations, dataConnections, input, null, null);
            //now pull out estimated durations
            if (dataMergedRequirements.TargetCredential != null && dataMergedRequirements.TargetCredential.Any())
            {
                output.CredentialEstimatedDuration = ServiceHelper.GetAllDurations(dataMergedRequirements.CredentialsSansSelf(input.Id), "Estimated Time to Complete Required Embedded Credentials");
            }
            if (dataMergedRequirements.TargetAssessment != null && dataMergedRequirements.TargetAssessment.Any())
            {
                //output.AssessmentEstimatedDuration = ServiceHelper.GetAllDurationsOLD( dataMergedRequirements.TargetAssessment, "Estimated Time to Complete Required Assessments" );
                output.AssessmentEstimatedDuration = ServiceHelper.GetAllDurations(dataMergedRequirements.TargetAssessment, "Estimated Time to Complete Required Assessments");
            }
            if (dataMergedRequirements.TargetLearningOpportunity != null && dataMergedRequirements.TargetLearningOpportunity.Any())
            {
                output.LearningOpportunityEstimatedDuration = ServiceHelper.GetAllDurations(dataMergedRequirements.TargetLearningOpportunity, "Estimated Time to Complete Required Learning Opportunities");
            }


            //competencies
            var dataAllCompetencies = ServiceHelper.GetAllCompetencies(dataMergedRequirements);

            var allCompetencies = dataAllCompetencies.RequiresByFramework
                                  .Concat(dataAllCompetencies.AssessesByFramework)
                                  .Concat(dataAllCompetencies.TeachesByFramework)
                                  .ToList();
            var allFrameWorks = new Dictionary <string, List <string> >();

            foreach (var frameWork in allCompetencies)
            {
                if (!string.IsNullOrWhiteSpace(frameWork.CaSSViewerUrl) && !allFrameWorks.ContainsKey(frameWork.CaSSViewerUrl ?? ""))
                {
                    allFrameWorks.Add(frameWork.CaSSViewerUrl, frameWork.Items.Select(m => m.TargetNode).ToList());
                }
            }
            var frameworkGraphs = new List <string>();

            foreach (var framework in allCompetencies)
            {
                var uri = (framework.FrameworkUri ?? "").Replace("/resources/", "/graph/");
                if (framework.IsARegistryFrameworkUrl && framework.ExistsInRegistry)
                {
                    var frameworkData = RegistryServices.GetRegistryData("", uri);
                    if (!string.IsNullOrWhiteSpace(frameworkData) && frameworkData.IndexOf("<") != 0)                           //Avoid empty results and results like "<h2>Incomplete response received from application</h2>"
                    {
                        frameworkGraphs.Add(frameworkData);
                    }
                }
            }

            if (dataAllCompetencies.RequiresByFramework.Count() > 0)
            {
            }
            if (dataAllCompetencies.AssessesByFramework.Count() > 0)
            {
            }
            if (dataAllCompetencies.TeachesByFramework.Count() > 0)
            {
            }
            //=======================================
            try
            {
                //
                if (input.CommonCosts != null && input.CommonCosts.Any())
                {
                    output.CommonCosts   = ServiceHelper.MapCostManifests(input.CommonCosts, searchType);
                    output.EstimatedCost = new List <Models.Elastic.CostProfile>();
                    foreach (var item in output.CommonCosts)
                    {
                        output.EstimatedCost.AddRange(item.EstimatedCost);
                    }
                    output.CommonCosts = null;
                }

                if (input.EstimatedCost != null && input.EstimatedCost.Any())
                {
                    if (output.EstimatedCost == null)
                    {
                        output.EstimatedCost = new List <Models.Elastic.CostProfile>();
                    }

                    var estimatedCost = ServiceHelper.MapCostProfiles(input.EstimatedCost, searchType);
                    if (estimatedCost != null && estimatedCost.Any())
                    {
                        output.EstimatedCost.AddRange(estimatedCost);
                    }
                }
                //loop costs
                if (input.Requires.SelectMany(x => x.TargetLearningOpportunity.Where(y => y.EstimatedCost.Count() + y.CommonCosts.Count() > 0)).Count() > 0)
                {
                    var list = input.Requires.SelectMany(x => x.TargetLearningOpportunity).ToList();
                    foreach (var item in list)
                    {
                        if (item.CommonCosts.Any() || item.EstimatedCost.Any())
                        {
                            var commonCosts = ServiceHelper.MapCostManifests(item.CommonCosts, searchType);
                            output.LearningOpportunityCost = new List <Models.Elastic.CostProfile>();
                            if (commonCosts != null && commonCosts.Any())
                            {
                                foreach (var cc in commonCosts)
                                {
                                    output.LearningOpportunityCost.AddRange(cc.EstimatedCost);
                                }
                            }
                        }
                        //
                        if (item.EstimatedCost != null && item.EstimatedCost.Any())
                        {
                            if (output.LearningOpportunityCost == null)
                            {
                                output.LearningOpportunityCost = new List <Models.Elastic.CostProfile>();
                            }

                            var estimatedCost = ServiceHelper.MapCostProfiles(item.EstimatedCost, searchType);
                            if (estimatedCost != null && estimatedCost.Any())
                            {
                                output.LearningOpportunityCost.AddRange(estimatedCost);
                            }
                        }
                    }
                }
                //asmt costs
                if (input.Requires.SelectMany(x => x.TargetAssessment.Where(y => y.EstimatedCost.Count() + y.CommonCosts.Count() > 0)).Count() > 0)
                {
                    var list = input.Requires.SelectMany(x => x.TargetAssessment).ToList();
                    foreach (var item in list)
                    {
                        if (item.CommonCosts.Any() || item.EstimatedCost.Any())
                        {
                            var commonCosts = ServiceHelper.MapCostManifests(item.CommonCosts, searchType);
                            output.AssessmentCost = new List <Models.Elastic.CostProfile>();
                            if (commonCosts != null && commonCosts.Any())
                            {
                                foreach (var cc in commonCosts)
                                {
                                    output.AssessmentCost.AddRange(cc.EstimatedCost);
                                }
                            }
                        }
                        //
                        if (item.EstimatedCost.Any() || item.EstimatedCost.Any())
                        {
                            if (output.AssessmentCost == null)
                            {
                                output.AssessmentCost = new List <Models.Elastic.CostProfile>();
                            }

                            var estimatedCost = ServiceHelper.MapCostProfiles(item.EstimatedCost, searchType);
                            if (estimatedCost != null && estimatedCost.Any())
                            {
                                output.AssessmentCost.AddRange(estimatedCost);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LoggingHelper.LogError(ex, string.Format(thisClassName + ".MapToAPI. Section 3, Name: {0}, Id: [1}", input.Name, input.Id));
            }


            //
            if (input.FinancialAssistance != null && input.FinancialAssistance.Any())
            {
                output.FinancialAssistance = ServiceHelper.MapFinancialAssistanceProfiles(input.FinancialAssistance, searchType);
            }
            //
            output.CredentialId = input.CredentialId;
            output.ISICV4       = input.ISICV4;
            //InLanguage

            //
            output.Identifier = ServiceHelper.MapIdentifierValue(input.Identifier);
            //
            MapProcessProfiles(input, ref output);
            output.SameAs = ServiceHelper.MapTextValueProfileTextValue(input.SameAs);
            //
            //output.ProcessStandards = input.ProcessStandards;
            //output.ProcessStandardsDescription = input.ProcessStandardsDescription;
            output.ProcessStandards = ServiceHelper.MapPropertyLabelLink(input.ProcessStandards, "Process Standards", input.ProcessStandardsDescription);

            //
            output.Revocation = ServiceHelper.MapRevocationProfile(searchType, input.Revocation);

            //these are can be links to existing credentials, likely to be in finder
            output.LatestVersion   = ServiceHelper.MapPropertyLabelLink(input.LatestVersion, "Latest Version");
            output.NextVersion     = ServiceHelper.MapPropertyLabelLink(input.NextVersion, "Next Version");
            output.PreviousVersion = ServiceHelper.MapPropertyLabelLink(input.PreviousVersion, "Previous Version");
            output.Supersedes      = ServiceHelper.MapPropertyLabelLink(input.Supersedes, "Supersedes");
            output.SupersededBy    = ServiceHelper.MapPropertyLabelLink(input.SupersededBy, "Superseded By");
            //
            output.TargetPathway = ServiceHelper.MapPathwayToAJAXSettings(input.TargetPathway, "Has {0} Target Pathway(s)");

            //
            output.VersionIdentifier = ServiceHelper.MapIdentifierValue(input.VersionIdentifierList, "Version Identifier");
            try
            {
                MapJurisdictions(input, ref output);
                //
                //QA received
                //==> need to exclude 30-published by
                if (input.OrganizationRole.Any())
                {
                    output.QAReceived = ServiceHelper.MapQAReceived(input.OrganizationRole, searchType);
                    //old
                    var renewedBy2 = ServiceHelper.MapRoleReceived(input.OrganizationRole, searchType, Entity_AgentRelationshipManager.ROLE_TYPE_RenewedBy);
                    var revokedBy2 = ServiceHelper.MapRoleReceived(input.OrganizationRole, searchType, Entity_AgentRelationshipManager.ROLE_TYPE_RevokedBy);
                    //new
                    output.RenewedBy = ServiceHelper.MapOutlineToAJAX(renewedBy2, "Renewed by {0} Organization(s)");
                    output.RevokedBy = ServiceHelper.MapOutlineToAJAX(revokedBy2, "Revoked by {0} Organization(s)");
                }
            }
            catch (Exception ex)
            {
                LoggingHelper.LogError(ex, string.Format(thisClassName + ".MapToAPI. Section 4, Name: {0}, Id: [1}", input.Name, input.Id));
            }
            //



            //
            return(output);
        }
Ejemplo n.º 4
0
        private static MCD.LearningOpportunityDetail MapToAPI(ThisEntity input)
        {
            var searchType = "learningopportunity";
            var output     = new MCD.LearningOpportunityDetail()
            {
                Meta_Id               = input.Id,
                CTID                  = input.CTID,
                Name                  = input.Name,
                FriendlyName          = HttpUtility.UrlPathEncode(input.Name),
                Description           = input.Description,
                SubjectWebpage        = input.SubjectWebpage,
                EntityTypeId          = 7,
                CredentialRegistryURL = RegistryServices.GetResourceUrl(input.CTID),
                RegistryData          = ServiceHelper.FillRegistryData(input.CTID)
            };

            output.Meta_LastUpdated = input.EntityLastUpdated;
            output.Meta_StateId     = input.EntityStateId;
            if (input.InLanguageCodeList != null && input.InLanguageCodeList.Any())
            {
                //output.Meta_Language = input.InLanguageCodeList[ 0 ].TextTitle;
                output.InLanguage = new List <string>();
                foreach (var item in input.InLanguageCodeList)
                {
                    output.InLanguage.Add(item.TextTitle);
                }
            }
            if (input.OwningOrganizationId > 0)
            {
                output.OwnedByLabel = ServiceHelper.MapDetailLink("Organization", input.OrganizationName, input.OwningOrganizationId);
            }
            var work = ServiceHelper.MapOrganizationRoleProfileToOutline(input.OrganizationRole, Entity_AgentRelationshipManager.ROLE_TYPE_OWNER);

            output.OwnedBy = ServiceHelper.MapOutlineToAJAX(work, "");
            //
            work             = ServiceHelper.MapOrganizationRoleProfileToOutline(input.OrganizationRole, Entity_AgentRelationshipManager.ROLE_TYPE_OFFERED_BY);
            output.OfferedBy = ServiceHelper.MapOutlineToAJAX(work, "Offered by {0} Organization(s)");
            //
            //
            //QA for owner,not offerer
            if (input.OwningOrganization != null && input.OwningOrganization.Id > 0)
            {
                if (input.OwningOrganization.OrganizationRole_Recipient != null && input.OwningOrganization.OrganizationRole_Recipient.Any())
                {
                    output.OwnerQAReceived = ServiceHelper.MapQAReceived(input.OwningOrganization.OrganizationRole_Recipient, searchType);
                }
            }
            //
            output.AssessmentMethodType        = ServiceHelper.MapPropertyLabelLinks(input.AssessmentMethodType, searchType);
            output.AssessmentMethodDescription = input.AssessmentMethodDescription;

            if (!string.IsNullOrWhiteSpace(input.AvailabilityListing))
            {
                output.AvailabilityListing = new List <string>()
                {
                    input.AvailabilityListing
                }
            }
            ;
            if (!string.IsNullOrWhiteSpace(input.AvailableOnlineAt))
            {
                output.AvailableOnlineAt = new List <string>()
                {
                    input.AvailableOnlineAt
                }
            }
            ;
            //MapAddress( input, ref output );
            output.AvailableAt = ServiceHelper.MapAddress(input.Addresses);

            //
            output.AudienceLevelType         = ServiceHelper.MapPropertyLabelLinks(input.AudienceLevelType, searchType);
            output.AudienceType              = ServiceHelper.MapPropertyLabelLinks(input.AudienceType, searchType);
            output.CreditUnitTypeDescription = input.CreditUnitTypeDescription;
            output.CreditValue = ServiceHelper.MapValueProfile(input.CreditValue, searchType);

            //
            output.DateEffective           = input.DateEffective;
            output.ExpirationDate          = input.ExpirationDate;
            output.DeliveryType            = ServiceHelper.MapPropertyLabelLinks(input.DeliveryType, searchType);
            output.DeliveryTypeDescription = input.DeliveryTypeDescription;
            output.EstimatedDuration       = ServiceHelper.MapDurationProfiles(input.EstimatedDuration);
            //
            //CostProfiles
            if (input.CommonCosts != null && input.CommonCosts.Any())
            {
                output.CommonCosts   = ServiceHelper.MapCostManifests(input.CommonCosts, searchType);
                output.EstimatedCost = new List <Models.Elastic.CostProfile>();
                foreach (var item in output.CommonCosts)
                {
                    output.EstimatedCost.AddRange(item.EstimatedCost);
                }
                output.CommonCosts = null;
            }

            if (input.EstimatedCost != null && input.EstimatedCost.Any())
            {
                if (output.EstimatedCost == null)
                {
                    output.EstimatedCost = new List <Models.Elastic.CostProfile>();
                }

                var estimatedCost = ServiceHelper.MapCostProfiles(input.EstimatedCost, searchType);
                if (estimatedCost != null && estimatedCost.Any())
                {
                    output.EstimatedCost.AddRange(estimatedCost);
                }
            }
            //
            if (input.FinancialAssistance != null && input.FinancialAssistance.Any())
            {
                output.FinancialAssistance = ServiceHelper.MapFinancialAssistanceProfiles(input.FinancialAssistance, searchType);
            }

            //condition profiles
            output.Corequisite    = ServiceHelper.MapToConditionProfiles(input.Corequisite, searchType);
            output.EntryCondition = ServiceHelper.MapToConditionProfiles(input.EntryCondition, searchType);
            output.Recommends     = ServiceHelper.MapToConditionProfiles(input.Recommends, searchType);
            output.EntryCondition = ServiceHelper.MapToConditionProfiles(input.EntryCondition, searchType);
            output.Requires       = ServiceHelper.MapToConditionProfiles(input.Requires, searchType);
            //
            if (input.CommonConditions != null && input.CommonConditions.Any())
            {
                output.CommonConditions = ServiceHelper.MapConditionManifests(input.CommonConditions, searchType);
                if (output.CommonConditions != null && output.CommonConditions.Any())
                {
                    foreach (var item in output.CommonConditions)
                    {
                        if (item.Requires != null && item.Requires.Any())
                        {
                            output.Requires = ServiceHelper.AppendConditions(item.Requires, output.Requires);
                        }
                        if (item.Recommends != null && item.Recommends.Any())
                        {
                            output.Recommends = ServiceHelper.AppendConditions(item.Recommends, output.Recommends);
                        }
                        if (item.Corequisite != null && item.Corequisite.Any())
                        {
                            output.Corequisite = ServiceHelper.AppendConditions(item.Requires, output.Corequisite);
                        }
                        if (item.EntryCondition != null && item.EntryCondition.Any())
                        {
                            output.EntryCondition = ServiceHelper.AppendConditions(item.EntryCondition, output.EntryCondition);
                        }
                    }
                }
            }
            //
            //connection profiles
            output.AdvancedStandingFrom  = ServiceHelper.MapToConditionProfiles(input.AdvancedStandingFrom, searchType);
            output.IsAdvancedStandingFor = ServiceHelper.MapToConditionProfiles(input.IsAdvancedStandingFor, searchType);
            //
            output.PreparationFrom  = ServiceHelper.MapToConditionProfiles(input.PreparationFrom, searchType);
            output.IsPreparationFor = ServiceHelper.MapToConditionProfiles(input.IsPreparationFor, searchType);
            //
            output.IsRequiredFor    = ServiceHelper.MapToConditionProfiles(input.IsRequiredFor, searchType);
            output.IsRecommendedFor = ServiceHelper.MapToConditionProfiles(input.IsRecommendedFor, searchType);
            //
            //
            if (input.HasPart != null && input.HasPart.Any())
            {
                output.HasPart = new List <MCD.Outline>();
                foreach (var target in input.HasPart)
                {
                    if (target != null && !string.IsNullOrWhiteSpace(target.Name))
                    {
                        output.HasPart.Add(ServiceHelper.MapToOutline(target, searchType));
                    }
                }
            }
            //
            if (input.IsPartOf != null && input.IsPartOf.Any())
            {
                output.IsPartOf = new List <MCD.Outline>();
                foreach (var target in input.IsPartOf)
                {
                    if (target != null && !string.IsNullOrWhiteSpace(target.Name))
                    {
                        output.IsPartOf.Add(ServiceHelper.MapToOutline(target, searchType));
                    }
                }
            }
            //
            output.Identifier = ServiceHelper.MapIdentifierValue(input.Identifier);
            //
            output.IndustryType             = ServiceHelper.MapReferenceFrameworkLabelLink(input.IndustryType, searchType, CodesManager.PROPERTY_CATEGORY_NAICS);
            output.OccupationType           = ServiceHelper.MapReferenceFrameworkLabelLink(input.OccupationType, searchType, CodesManager.PROPERTY_CATEGORY_SOC);
            output.InstructionalProgramType = ServiceHelper.MapReferenceFrameworkLabelLink(input.InstructionalProgramType, searchType, CodesManager.PROPERTY_CATEGORY_CIP);
            output.IsReferenceVersion       = input.IsReferenceVersion;
            //
            MapJurisdictions(input, ref output);

            //
            if (input.Keyword != null && input.Keyword.Any())
            {
                output.Keyword = ServiceHelper.MapPropertyLabelLinks(input.Keyword, searchType);
            }
            if (input.Subject != null && input.Subject.Any())
            {
                output.Subject = ServiceHelper.MapPropertyLabelLinks(input.Subject, searchType);
            }
            //
            output.LearningMethodType        = ServiceHelper.MapPropertyLabelLinks(input.LearningMethodType, searchType);
            output.LearningMethodDescription = input.LearningMethodDescription;
            //
            //none yet, leave here for likely additions
            //MapProcessProfiles( input, ref output );
            //
            output.SameAs = ServiceHelper.MapTextValueProfileTextValue(input.SameAs);
            //
            output.VersionIdentifier = ServiceHelper.MapIdentifierValue(input.VersionIdentifierList, "Version Identifier");
            //QA received
            //==> need to exclude 30-published by
            if (input.OrganizationRole.Any())
            {
                output.QAReceived = ServiceHelper.MapQAReceived(input.OrganizationRole, searchType);
            }

            return(output);
        }
Ejemplo n.º 5
0
        private static WMA.OrganizationDetail MapToAPI(Organization input, OrganizationManager.OrganizationRequest request)
        {
            var output = new WMA.OrganizationDetail()
            {
                Meta_Id               = input.Id,
                Name                  = input.Name,
                FriendlyName          = HttpUtility.UrlPathEncode(input.Name),
                Description           = input.Description,
                SubjectWebpage        = input.SubjectWebpage,
                EntityTypeId          = 2,
                CredentialRegistryURL = RegistryServices.GetResourceUrl(input.CTID),
                RegistryData          = ServiceHelper.FillRegistryData(input.CTID)
            };

            if (input.ISQAOrganization)
            {
                output.CTDLType      = "ceterms:QACredentialOrganization";
                output.CTDLTypeLabel = "Quality Assurance Organization";
            }
            else
            {
                output.CTDLType      = "ceterms:CredentialOrganization";
                output.CTDLTypeLabel = "Credentialing Organization";
            }

            //output.CTDLType = record.AgentDomainType;
            output.AgentSectorType = ServiceHelper.MapPropertyLabelLinks(input.AgentSectorType, "organization");
            output.AgentType       = ServiceHelper.MapPropertyLabelLinks(input.AgentType, "organization");
            //TODO consider using LabelLink to provide both the URL and description
            output.AgentPurpose = ServiceHelper.MapPropertyLabelLink(input.AgentPurpose, "Purpose", input.AgentPurposeDescription);
            //output.AgentPurpose = ServiceHelper.MapPropertyLabelLink( input.AgentPurpose, "Purpose" );

            //output.AgentPurposeDescription = input.AgentPurposeDescription;
            //
            output.AlternateName = input.AlternateName;
            if (!string.IsNullOrWhiteSpace(input.AvailabilityListing))
            {
                output.AvailabilityListing = new List <string>()
                {
                    input.AvailabilityListing
                }
            }
            ;
            else
            {
                output.AvailabilityListing = input.AvailabilityListings;
            }
            //
            output.CTID = input.CTID;
            if (input.Emails != null && input.Emails.Any())
            {
                output.Email = input.Emails.Select(s => s.TextValue).ToList();
            }

            output.Meta_LastUpdated = input.EntityLastUpdated;
            output.Meta_StateId     = input.EntityStateId;
            output.EntityTypeId     = input.EntityTypeId;
            output.FoundingDate     = input.FoundingDate;
            output.FriendlyName     = input.FriendlyName;
            //identifiers
            output.Identifier = ServiceHelper.MapIdentifierValue(input.Identifier);
            output.DUNS       = input.ID_DUNS;
            output.FEIN       = input.ID_FEIN;
            output.IPEDSID    = input.ID_IPEDSID;
            output.ISICV4     = input.ID_ISICV4;
            output.LEICode    = input.ID_LEICode;
            output.NECS       = input.ID_NECS;
            output.OPEID      = input.ID_OPEID;
            //
            output.Image        = input.Image;
            output.IndustryType = ServiceHelper.MapReferenceFrameworkLabelLink(input.IndustryType, searchType, CodesManager.PROPERTY_CATEGORY_NAICS);
            //output.IsReferenceVersion = record.IsReferenceVersion;
            //
            if (input.Keyword != null && input.Keyword.Any())
            {
                output.Keyword = ServiceHelper.MapPropertyLabelLinks(input.Keyword, "organization");
            }


            //output.MissionAndGoalsStatement = ServiceHelper.MapPropertyLabelLink( input.MissionAndGoalsStatement, "Mission Statement" );
            //output.MissionAndGoalsStatementDescription = input.MissionAndGoalsStatementDescription;
            output.MissionAndGoalsStatement = ServiceHelper.MapPropertyLabelLink(input.MissionAndGoalsStatement, "Mission Statement", input.MissionAndGoalsStatementDescription);

            //this is NOT pertinent to organization
            //output.OrganizationId = org.OrganizationId;
            //output.OrganizationName = org.OrganizationName;
            //output.OrganizationSubjectWebpage = "";
            output.ServiceType = ServiceHelper.MapPropertyLabelLinks(input.ServiceType, "organization");
            output.SameAs      = ServiceHelper.MapTextValueProfileTextValue(input.SameAs);
            output.SocialMedia = ServiceHelper.MapTextValueProfileTextValue(input.SocialMediaPages);

            //output.TransferValueStatement = ServiceHelper.MapPropertyLabelLink( input.TransferValueStatement, "Transfer Value Statement" );
            //output.TransferValueStatementDescription = input.TransferValueStatementDescription;
            output.TransferValueStatement = ServiceHelper.MapPropertyLabelLink(input.TransferValueStatement, "Transfer Value Statement", input.TransferValueStatementDescription);


            //input.FriendlyName = HttpUtility.UrlPathEncode ( input.Name );
            //searches
            var links = new List <WMA.LabelLink>();

            output.Connections = null;
            if (input.TotalCredentials > 0)
            {
                //output.CredentialsSearch = ServiceHelper.MapEntitySearchLink( org.Id, org.Name, org.TotalCredentials, "Owns/Offers {0} Credential(s)", "credential" );

                //output.Connections.Add( output.CredentialsSearch );
                ServiceHelper.MapEntitySearchLink(input.Id, input.Name, input.TotalCredentials, "Owns/Offers {0} Credential(s)", "credential", ref links);
            }
            if (input.TotalLopps > 0)
            {
                ServiceHelper.MapEntitySearchLink(input.Id, input.Name, input.TotalLopps, "Owns/Offers {0} Learning Opportunity(ies)", "learningopportunity", ref links);
            }
            if (input.TotalAssessments > 0)
            {
                ServiceHelper.MapEntitySearchLink(input.Id, input.Name, input.TotalAssessments, "Owns/Offers {0} Assesment(s)", "assessment", ref links);
            }

            if (input.TotalPathwaySets > 0)
            {
                ServiceHelper.MapEntitySearchLink(input.Id, input.Name, input.TotalPathwaySets, "Owns {0} Pathway Set(s)", "pathwayset", ref links);
            }
            if (input.TotalPathways > 0)
            {
                ServiceHelper.MapEntitySearchLink(input.Id, input.Name, input.TotalPathways, "Owns {0} Pathway(s)", "pathway", ref links);
            }
            if (input.TotalTransferValueProfiles > 0)
            {
                ServiceHelper.MapEntitySearchLink(input.Id, input.Name, input.TotalTransferValueProfiles, "Owns {0} Transfer Value Profiles(s)", "transfervalue", ref links);
            }

            if (input.TotalFrameworks > 0)
            {
                ServiceHelper.MapEntitySearchLink(input.Id, input.Name, input.TotalFrameworks, "Owns {0} Competency Framework(s)", "competencyframework", ref links);
            }

            if (input.TotalConceptSchemes > 0)
            {
                ServiceHelper.MapEntitySearchLink(input.Id, input.Name, input.TotalConceptSchemes, "Owns {0} Concept Scheme(s)", "conceptscheme", ref links);
            }

            //21-03-10 combining revokes and renews
            if (input.RevokesCredentials > 0 || input.RenewsCredentials > 0)
            {
                ServiceHelper.MapEntitySearchLink(input.Id, input.Name, input.RevokesCredentials + input.RenewsCredentials, "Renews/Revokes {0} Credential(s)", "credential", ref links, "11, 13");
            }
            //if ( org.RegulatesCredentials > 0 )
            //	ServiceHelper.MapEntitySearchLink( org.Id, org.Name, org.RegulatesCredentials, "Regulates {0} Credential(s)", "credential", ref links, "12" );
            //if ( input.RenewsCredentials > 0 )
            //	ServiceHelper.MapEntitySearchLink( input.Id, input.Name, input.RenewsCredentials, "Renews {0} Credential(s)", "credential", ref links, "13" );

            //
            if (links.Any())
            {
                output.Connections = links;
            }
            //need to handle other roles: renews, revokes, regulates
            //QA performed
            output.QAPerformed = new List <WMA.LabelLink>();
            links = new List <WMA.LabelLink>();
            if (input.QAPerformedOnCredentialsCount > 0)
            {
                ServiceHelper.MapQAPerformedLink(input.Id, input.Name, input.QAPerformedOnCredentialsCount, "QA Identified as Performed on {0} Credential(s)", "credential", ref links);
            }

            if (input.QAPerformedOnOrganizationsCount > 0)
            {
                ServiceHelper.MapQAPerformedLink(input.Id, input.Name, input.QAPerformedOnOrganizationsCount, "QA Identified as Performed on {0} Organization(s)", "organization", ref links);
            }
            if (input.QAPerformedOnAssessmentsCount > 0)
            {
                ServiceHelper.MapQAPerformedLink(input.Id, input.Name, input.QAPerformedOnAssessmentsCount, "QA Identified as Performed on {0} Assessment(s)", "assessment", ref links);
            }

            if (input.QAPerformedOnLoppsCount > 0)
            {
                ServiceHelper.MapQAPerformedLink(input.Id, input.Name, input.QAPerformedOnLoppsCount, "QA Identified as Performed on {0} Learning Opportunity(ies)", "learningopportunity", ref links);
            }

            if (links.Any())
            {
                output.QAPerformed = links;
            }

            //21-03-12 these should be populated now. Be sure to remove them from QaReceived.
            //need to be consistent. Seems this property will use acting agent, but dept/sub will use participating agent
            output.ParentOrganization = ServiceHelper.MapOrganizationRoleProfileToAJAX(input.ParentOrganizations, "Has Parent Organization");
            if (input.ParentOrganization != null && input.ParentOrganization.Any())
            {
                var parents = ServiceHelper.MapOrganizationRoleProfileToOutline(input.ParentOrganizations, Entity_AgentRelationshipManager.ROLE_TYPE_PARENT_ORG);
                if (parents != null && parents.Any())
                {
                    //just return one for now
                    //output.ParentOrganizationOutline = parents[ 0 ];
                }
            }
            //
            output.Department      = ServiceHelper.MapOrganizationRoleProfileToAJAX(input.OrganizationRole_Dept, "Has {0} Departments(s)");
            output.SubOrganization = ServiceHelper.MapOrganizationRoleProfileToAJAX(input.OrganizationRole_Subsidiary, "Has {0} Suborganization(s)");
            //

            //QAReceived
            //==> need to exclude 30-published by
            //also check for 20, 21 and move to dept, subsidiary, parent
            var qaroles = "1,2,10,12";

            if (input.OrganizationRole_Recipient.Any())
            {
                output.QAReceived = ServiceHelper.MapQAReceived(input.OrganizationRole_Recipient, searchType);

                /*
                 * output.QAReceived = new List<WMA.OrganizationRoleProfile>();
                 * foreach ( var item in input.OrganizationRole_Recipient )
                 * {
                 *      var orp = new WMA.OrganizationRoleProfile()
                 *      {
                 *              Label = string.IsNullOrWhiteSpace( item.ProfileName ) ? item.ParentSummary : item.ProfileName,
                 *              Description = item.Description ?? ""
                 *      };
                 *      if ( string.IsNullOrWhiteSpace( orp.Label ) )
                 *      {
                 *              if ( item.ActingAgent != null && item.ActingAgent.Id > 0 )
                 *              {
                 *                      orp.Label = item.ActingAgent.Name;
                 *                      orp.Description = item.ActingAgent.Description;
                 *              }
                 *      }
                 *      if ( string.IsNullOrEmpty( item.ActingAgent.CTID ) )
                 *              orp.URL = item.ActingAgent.SubjectWebpage;
                 *      else
                 *              orp.URL = externalFinderSiteURL + string.Format( "organization/{0}", input.Id );
                 *      bool isPublishedByRole = false;
                 *      if ( item.AgentRole != null && item.AgentRole.Items.Any() )
                 *      {
                 *              foreach ( var ar in item.AgentRole.Items )
                 *              {
                 *                      //no link
                 *                      if ( ar.Id == 30 )
                 *                      {
                 *                              //if published by, probably will not have other roles!
                 *                              //continue;
                 *                              isPublishedByRole = true;
                 *                              break;
                 *                      } else if ( ar.Id == 20 || ar.Id == 21 || ar.Id == 22)
                 *                      {
                 *                              //skip dept, subsidiary and parent
                 *                              continue;
                 *                      }
                 *                      //should this be the reverseTitle?
                 *                      if ( item.ActingAgent != null && item.ActingAgent.Id > 0 )
                 *                      {
                 *                              //if role is QA, include all 4 in link
                 *                              ServiceHelper.MapEntitySearchLink( item.ActingAgent.Id, item.ActingAgent.Name, 0, ar.Name, searchType, ref orp.Roles, qaroles );//ar.Id.ToString()
                 *                      } else
                 *                              orp.Roles.Add( new WMA.LabelLink() { Label = ar.Name } );
                 *              }
                 *      }
                 *      if ( !isPublishedByRole && orp.Roles.Any() )
                 *              output.QAReceived.Add( orp );
                 * }
                 */
            }
            //
            MapAddress(input, ref output);

            if (request.IncludingManifests)
            {
            }
            else
            {
            }
            //manifests
            MapManifests(input, ref output, request);


            //process profiles
            MapProcessProfiles(input, ref output, request);

            //
            MapJurisdictions(input, ref output);
            //
            MapVerificationServiceProfile(input, ref output, request);

            return(output);
        }
        private static WMA.TransferValueProfile MapToAPI(ThisEntity input)
        {
            var output = new WMA.TransferValueProfile()
            {
                Meta_Id               = input.Id,
                CTID                  = input.CTID,
                Name                  = input.Name,
                FriendlyName          = HttpUtility.UrlPathEncode(input.Name),
                Description           = input.Description,
                SubjectWebpage        = input.SubjectWebpage,
                EntityTypeId          = 26,
                StartDate             = input.StartDate,
                EndDate               = input.EndDate,
                CredentialRegistryURL = RegistryServices.GetResourceUrl(input.CTID),
                RegistryData          = ServiceHelper.FillRegistryData(input.CTID)
            };

            if (input.OwningOrganizationId > 0)
            {
                output.OwnedByLabel = ServiceHelper.MapDetailLink("Organization", input.OrganizationName, input.OwningOrganizationId);
            }

            var orgOutline = ServiceHelper.MapToOutline(input.OwningOrganization, "organization");

            //var work = ServiceHelper.MapOrganizationRoleProfileToOutline( input.OrganizationRole, Entity_AgentRelationshipManager.ROLE_TYPE_OWNER );
            output.OwnedBy = ServiceHelper.MapOutlineToAJAX(orgOutline, "Owning Organization");
            //
            //
            output.Identifier = ServiceHelper.MapIdentifierValue(input.Identifier);
            //transferValue
            output.TransferValue = ServiceHelper.MapValueProfile(input.TransferValue, "");
            //for
            var work = new List <WMA.Outline>();

            foreach (var target in input.TransferValueFor)
            {
                if (target != null && !string.IsNullOrWhiteSpace(target.Name))
                {
                    work.Add(ServiceHelper.MapToOutline(target, ""));
                }
            }
            output.TransferValueFor = ServiceHelper.MapOutlineToAJAX(work, "Includes {0} Transfer Value For");

            //from
            work = new List <WMA.Outline>();
            foreach (var target in input.TransferValueFrom)
            {
                if (target != null && !string.IsNullOrWhiteSpace(target.Name))
                {
                    work.Add(ServiceHelper.MapToOutline(target, ""));
                }
            }
            output.TransferValueFrom = ServiceHelper.MapOutlineToAJAX(work, "Includes {0} Transfer Value From");
            //
            if (input.DevelopmentProcess.Any())
            {
                output.DevelopmentProcess = ServiceHelper.MapAJAXProcessProfile("Development Process", "", input.DevelopmentProcess);
            }

            //
            output.InLanguage = null;
            return(output);
        }