예제 #1
0
 public List <Term> Terms(string url, Guid sspId, int lcid, Guid termSetId, Guid termId)
 {
     using (var tax = new TaxonomyService(url, credentials.Get(url)))
     {
         return(ParseXml(tax.GetChildTermsInTerm(sspId, lcid, termId, termSetId)).ToList());
     }
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        ScriptHelper.RegisterScriptFile(Page, "~/CMSScripts/Laureus/jquery/jquery-3.3.1.min.js");
        ScriptHelper.RegisterScriptFile(Page, "~/CMSScripts/Laureus/jsTree/jstree.min.js");
        CssRegistration.RegisterCssLink(Page, "~/CMSScripts/Laureus/jsTree/themes/default/style.min.css");

        var taxonomyService = new TaxonomyService(new TaxonomyRepository());

        TaxonomyTree = JsonConvert.SerializeObject(taxonomyService.GetTaxonomyTree(TargetTaxonomyTypes));
    }
        public ActionResult Edit(SpeciesEditViewModel viewModel)
        {
            Species         species          = new Species();
            ResultContainer resultContainer  = new ResultContainer();
            TaxonomyService _taxonomyService = new TaxonomyService(AuthenticatedUserSession.Environment);

            if (!ModelState.IsValid)
            {
                return(View("~/Views/Taxonomy/Species/Edit.cshtml", viewModel));
            }

            try
            {
                species.ID                  = viewModel.ID;
                species.SpeciesName         = viewModel.SpeciesName;
                species.Name                = viewModel.Name;
                species.GenusID             = viewModel.GenusID;
                species.GenusName           = viewModel.GenusName;
                species.Protologue          = viewModel.Protologue;
                species.Authority           = viewModel.Authority;
                species.IsSpecificHybrid    = viewModel.IsSpecificHybrid;
                species.IsSubSpecificHybrid = viewModel.IsSubSpecificHybrid;
                species.IsVarietalHybrid    = viewModel.IsVarietalHybrid;
                species.IsSubVarietalHybrid = viewModel.IsSubVarietalHybrid;
                species.FormaName           = viewModel.FormaName;
                species.FormaAuthority      = viewModel.FormaAuthority;
                species.FormaRankType       = viewModel.FormaRankType;
                species.Note                = viewModel.Note;

                if (viewModel.ID > 0)
                {
                    species.ModifiedByCooperatorID = AuthenticatedUser.CooperatorID;
                    resultContainer = _taxonomyService.UpdateSpecies(species);
                }
                else
                {
                    species.CreatedByCooperatorID = AuthenticatedUser.CooperatorID;
                    resultContainer = _taxonomyService.AddSpecies(species);
                    viewModel.ID    = resultContainer.EntityID;
                }

                if (resultContainer.ResultCode == "2601")
                {
                    viewModel.ErrorMessage = "The species name must be unique.";
                    return(View("~/Views/Taxonomy/Species/Edit.cshtml", viewModel));
                }

                return(RedirectToAction("Edit", "Taxonomy/Species", new { id = viewModel.ID }));
            }
            catch (Exception ex)
            {
                Log.Error(ex, ex.Message + ex.StackTrace);
                return(RedirectToAction("InternalServerError", "Error"));
            }
        }
        public TaxonomyValidatorTests()
        {
            var loggerMock            = new Mock <ILogger <TaxonomyService> >();
            var validationServiceMock = new Mock <IValidationService>();
            var metadataServiceMock   = new Mock <IMetadataService>();
            var cacheServiceMock      = new Mock <ICacheService>();

            var mathematicalTaxonomy = new TaxonomySchemeBuilder().GenerateSampleMathematicalTaxonomyList().Build();
            var informationClassificationTaxonomy = new TaxonomySchemeBuilder().GenerateSampleInformationClassificationTaxonomyList().Build();

            var taxonomyRepoMock = new Mock <ITaxonomyRepository>();

            taxonomyRepoMock.Setup(t => t.GetTaxonomies(Graph.Metadata.Constants.Resource.Type.MathematicalModelCategory)).Returns(mathematicalTaxonomy);
            taxonomyRepoMock.Setup(t => t.GetTaxonomies(Graph.Metadata.Constants.Resource.Type.InformationClassification)).Returns(informationClassificationTaxonomy);

            cacheServiceMock.Setup(t => t.GetOrAdd(It.IsAny <string>(), It.IsAny <Func <IList <Taxonomy> > >())).Returns(
                (string key, Func <IList <Taxonomy> > function) => function());
            cacheServiceMock.Setup(t => t.GetOrAdd(It.IsAny <string>(), It.IsAny <Func <IList <TaxonomyResultDTO> > >())).Returns(
                (string key, Func <IList <TaxonomyResultDTO> > function) => function());
            var pidUriTemplateServiceMock = new Mock <IPidUriTemplateService>();


            pidUriTemplateServiceMock.Setup(t => t.GetFlatPidUriTemplateByPidUriTemplate(It.IsAny <Entity>()))
            .Returns(null as PidUriTemplateFlattened);
            pidUriTemplateServiceMock.Setup(t => t.GetFlatPidUriTemplateByPidUriTemplate(It.IsAny <Entity>()))
            .Returns(null as PidUriTemplateFlattened);
            pidUriTemplateServiceMock.Setup(t => t.FormatPidUriTemplateName(It.IsAny <PidUriTemplateFlattened>()))
            .Returns(string.Empty);

            var serviceCollection = new ServiceCollection();

            serviceCollection.AddTransient <TaxonomyNameResolver>(t => new TaxonomyNameResolver(pidUriTemplateServiceMock.Object));

            var serviceProvider = serviceCollection.BuildServiceProvider();


            var config = new MapperConfiguration(cfg =>
            {
                cfg.ConstructServicesUsing(serviceProvider.GetService);
                cfg.AddProfile(new TaxonomyProfile());
            });

            var mapper = config.CreateMapper();

            var taxonomyService = new TaxonomyService(mapper, metadataServiceMock.Object, validationServiceMock.Object, taxonomyRepoMock.Object, loggerMock.Object, cacheServiceMock.Object);

            _validator = new TaxonomyValidator(taxonomyService);

            _metadata = new MetadataBuilder()
                        .GenerateSampleHasInformationClassifikation()
                        .GenerateSampleMathematicalCategory()
                        .Build();
        }
예제 #5
0
        public List <Term> GetCreateKeywords(string url, int lcid, IEnumerable <string> labels)
        {
            var terms = new List <Term>();

            using (var tax = new TaxonomyService(url, credentials.Get(url)))
            {
                foreach (var label in labels)
                {
                    var termDefinitionXml = tax.GetTermsByLabel(label, lcid, WebServices.TaxonomyClientService.StringMatchOption.ExactMatch, resultCollectionSize: 1, termIds: string.Empty, addIfNotFound: true);
                    terms.Add(ParseXml(termDefinitionXml).FirstOrDefault());
                }
            }
            return(terms);
        }
예제 #6
0
        public bool CheckKMTaxonomyService(int oid, ref int count, ref string errorMsg)
        {
            count = -1;
            WSPMNode[] nodes = null;
            try
            {
                TaxonomyService taxonomyService = new TaxonomyService();
                taxonomyService.SetConnectionInfo(base.taxonomyUrl, base.userId, base.userPassword, base.timeOut);

                HP.Csn.Business.KM.Services.TaxonomyService.WSUserInfo wsUserInfo = new HP.Csn.Business.KM.Services.TaxonomyService.WSUserInfo();
                wsUserInfo.userId   = base.userId;
                wsUserInfo.portalId = base.portalId;
                //wsUserInfo.protalId = base.portalId;

                WSPMRequest pmRequest = new WSPMRequest();
                pmRequest.oid    = oid;
                pmRequest.locale = DEFAULT_LANGUAGECODE;

                nodes = taxonomyService.retrievePMSubtree(wsUserInfo, pmRequest);
            }
            catch (SoapException ex)
            {
                errorMsg = "Error While Retrieving Taxonomy : (" + ex.Message + ")";
                return(false);
            }
            catch (System.Net.WebException ex)
            {
                errorMsg = "Error Connecting To Webservices : (" + ex.Message + ")";
                return(false);
            }
            catch (Exception ex)
            {
                errorMsg = "Unexpected Error While Accessing Webservices. ERROR : (" + ex.Message + ")";
                return(false);
            }

            count = 0;
            if (nodes != null && nodes.Length != 0)
            {
                count = nodes.Length;
            }
            else
            {
                errorMsg = "Taxonomy Not Available For Given OID :" + oid;
            }

            return(true);
        }
        public ActionResult AddSubTaxa(int id)
        {
            TempData["context"] = "Add SubTaxa";
            AddSubTaxaViewModel addSubTaxaViewModel = new AddSubTaxaViewModel();
            Species             species             = null;

            try
            {
                TaxonomyService _taxonomyService = new TaxonomyService(AuthenticatedUserSession.Environment);
                species = _taxonomyService.GetSpecies(id);
                addSubTaxaViewModel.SpeciesName   = species.Name;
                addSubTaxaViewModel.GenusName     = species.GenusName;
                addSubTaxaViewModel.NameAuthority = species.NameAuthority;
                addSubTaxaViewModel.Protologue    = species.Protologue;
                addSubTaxaViewModel.ProtologueURL = species.ProtologueVirtualPath;
            }
            catch (Exception ex)
            {
            }
            return(View(BASE_PATH + "/AddSubTaxa.cshtml", addSubTaxaViewModel));
        }
예제 #8
0
 public AnimalController(AnimalService animalService, TaxonomyService taxonomyService)
 {
     _animalService   = animalService;
     _taxonomyService = taxonomyService;
 }
예제 #9
0
 public TaxonomyController(TaxonomyService taxonomyService)
 {
     _taxonomyService = taxonomyService;
 }
        public ActionResult Edit(int id = 0)
        {
            Species species = null;
            SpeciesEditViewModel viewModel = null;

            TaxonomyService _taxonomyService = new TaxonomyService(AuthenticatedUserSession.Environment);

            try
            {
                if (id > 0)
                {
                    TempData["context"] = "Edit Species";
                    species             = _taxonomyService.GetSpecies(id);
                    viewModel           = new SpeciesEditViewModel();
                    viewModel.ID        = species.ID;
                    viewModel.CurrentTaxonomySpeciesID = species.CurrentTaxonomySpeciesID;
                    viewModel.NomenNumber              = species.NomenNumber;
                    viewModel.IsSpecificHybrid         = species.IsSpecificHybrid;
                    viewModel.SpeciesName              = species.SpeciesName;
                    viewModel.Name                     = species.Name;
                    viewModel.IsAcceptedName           = species.IsAcceptedName;
                    viewModel.Authority                = species.Authority;
                    viewModel.IsSubSpecificHybrid      = species.IsSubSpecificHybrid;
                    viewModel.SubSpeciesName           = species.SubSpeciesName;
                    viewModel.SubSpeciesAuthority      = species.SubSpeciesAuthority;
                    viewModel.IsVarietalHybrid         = species.IsVarietalHybrid;
                    viewModel.VarietyName              = species.VarietyName;
                    viewModel.VarietyAuthority         = species.VarietyAuthority;
                    viewModel.FormaName                = species.FormaName;
                    viewModel.FormaAuthority           = species.FormaAuthority;
                    viewModel.FormaRankType            = species.FormaRankType;
                    viewModel.GenusID                  = species.GenusID;
                    viewModel.GenusName                = species.GenusName;
                    viewModel.Protologue               = species.Protologue;
                    viewModel.NameAuthority            = species.NameAuthority;
                    viewModel.GenusID                  = species.GenusID;
                    viewModel.GenusName                = species.GenusName;
                    viewModel.Authority                = species.Authority;
                    viewModel.CreatedDate              = species.CreatedDate;
                    viewModel.CreatedByCooperatorID    = species.CreatedByCooperatorID;
                    viewModel.CreatedByCooperatorName  = species.CreatedByCooperatorName;
                    viewModel.ModifiedDate             = species.ModifiedDate;
                    viewModel.ModifiedByCooperatorID   = species.ModifiedByCooperatorID;
                    viewModel.ModifiedByCooperatorName = species.ModifiedByCooperatorName;
                    viewModel.Note                     = species.Note;
                    viewModel.Citations                = species.Citations;
                    viewModel.CommonNames              = species.CommonNames;
                    //viewModel.Usages = species.Usages;
                    //viewModel.RegulationMappings = species.RegulationMappings;
                }
                else
                {
                    TempData["context"] = "Add Species";
                    viewModel           = new SpeciesEditViewModel();
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex, ex.Message + ex.StackTrace);
                return(RedirectToAction("InternalServerError", "Error"));
            }
            return(View(BASE_PATH + "/Edit.cshtml", viewModel));
        }
예제 #11
0
        private DataTable BuildCVTaxonomy(string partnerRole)
        {
            TaxonomyService taxonomyService = new TaxonomyService();

            taxonomyService.SetConnectionInfo(base.taxonomyUrl, base.userId, base.userPassword, base.timeOut);

            WSUserInfo wsUserInfo = new WSUserInfo();

            wsUserInfo.userId   = base.userId;
            wsUserInfo.portalId = base.portalId;

            OracleUtil objOraUtil = new OracleUtil();

            wsUserInfo.disclosureLevels = objOraUtil.GetDisclosurelevel(partnerRole);

            WSCVRequest cvRequest = new WSCVRequest();

            cvRequest.taxoId = base.component_root_oid;           //COMPONENT_ROOT_OID;
            cvRequest.locale = DEFAULT_LANGUAGECODE;              // Release 8.7 Enhancement
            WSCVNode[] nodes = null;
            try
            {
                nodes = taxonomyService.retrieveCV(wsUserInfo, cvRequest);
            }
            catch (SoapException ex)
            {
                throw new TaxonomyException(3, TaxonomyException.ERROR_TYPE.INFORMATION, "Error While Retrieving Taxonomy", ex.Message, ex);
            }
            catch (System.Net.WebException ex)
            {
                throw new TaxonomyException(2, TaxonomyException.ERROR_TYPE.WARNING, "Error Connecting To Webservices", ex.Message, ex);
            }
            catch (Exception ex)
            {
                throw new TaxonomyException(1, TaxonomyException.ERROR_TYPE.WARNING, "Unexpected Error While Retrieving Taxonomy", ex.Message, ex);
            }

            if (nodes == null || nodes.Length == 0)
            {
                throw new TaxonomyException(4, TaxonomyException.ERROR_TYPE.INFORMATION, "Taxonomy Not Available For Given OID", "OID Node Is Empty");
            }

            DataTable retTaxonomy = CreateTaxonomyTable();

            for (int iCnt = 0; iCnt < nodes.Length; iCnt++)
            {
                DataRow row = retTaxonomy.NewRow();
                row["OID"]         = nodes[iCnt].oid;
                row["ParentID"]    = nodes[iCnt].parents[0];
                row["Description"] = nodes[iCnt].displayName;
                retTaxonomy.Rows.Add(row);
            }
            //sorting & storing...
            DataView dvSortedTaxonomy = new DataView(retTaxonomy);

            dvSortedTaxonomy.Sort = "Description";
            DataTable dtSortedTaxonomy = CreateTaxonomyTable();

            for (int iCnt = 0; iCnt < dvSortedTaxonomy.Count; iCnt++)
            {
                DataRow row = dtSortedTaxonomy.NewRow();
                row["OID"]         = dvSortedTaxonomy[iCnt]["OID"];
                row["ParentID"]    = dvSortedTaxonomy[iCnt]["ParentID"];
                row["Description"] = dvSortedTaxonomy[iCnt]["Description"];
                dtSortedTaxonomy.Rows.Add(row);
            }


            DateTime d          = DateTime.Now;
            DateTime d1         = new DateTime(d.Year, d.Month, d.Day, base.expiration_hrs, base.expiration_min, base.expiration_sec);
            long     expiration = (d1.Ticks - d.Ticks);

            if (expiration < 0)
            {
                expiration = TimeSpan.TicksPerDay + expiration;
            }
            expiration = expiration / TimeSpan.TicksPerSecond;
            int absoluteExpiration = Convert.ToInt32(expiration);
            int noSliding          = Cache.NoSlidingExpiration.Seconds;

            chTaxonomy.Insert("CSN_KM_TAXONOMY", "Taxonomy_CV", dtSortedTaxonomy, null, absoluteExpiration, noSliding);

            return(dtSortedTaxonomy);
        }
예제 #12
0
        /// <summary>
        /// methods, which implement the computations and actions that can be
        /// performed by the class
        /// </summary>
        #region "### Private Methods  ###"

        private DataTable BuildTaxonomy(int oid, int level, string partnerRole)
        {
            TaxonomyService taxonomyService = new TaxonomyService();

            taxonomyService.SetConnectionInfo(base.taxonomyUrl, base.userId, base.userPassword, base.timeOut);

            WSUserInfo wsUserInfo = new WSUserInfo();

            wsUserInfo.userId   = base.userId;
            wsUserInfo.portalId = base.portalId;

            OracleUtil objOraUtil = new OracleUtil();

            // Release 8.7 Enhancement
            wsUserInfo.disclosureLevels = objOraUtil.GetDisclosurelevel(partnerRole);

            WSPMRequest pmRequest = new WSPMRequest();

            pmRequest.oid    = oid;
            pmRequest.locale = DEFAULT_LANGUAGECODE;

            WSPMNode[] nodes = null;
            try
            {
                nodes = taxonomyService.retrievePMSubtree(wsUserInfo, pmRequest);
            }
            catch (SoapException ex)
            {
                throw new TaxonomyException(3, TaxonomyException.ERROR_TYPE.INFORMATION, "Error While Retrieving Taxonomy", ex.Message, ex);
            }
            catch (System.Net.WebException ex)
            {
                throw new TaxonomyException(2, TaxonomyException.ERROR_TYPE.WARNING, "Error Connecting To Webservices", ex.Message, ex);
            }
            catch (Exception ex)
            {
                throw new TaxonomyException(1, TaxonomyException.ERROR_TYPE.WARNING, "Unexpected Error While Retrieving Taxonomy", ex.Message, ex);
            }

            if (nodes == null || nodes.Length == 0)
            {
                throw new TaxonomyException(4, TaxonomyException.ERROR_TYPE.INFORMATION, "Taxonomy Not Available For Given OID", "OID Node Is Empty");
            }

            DataTable retTaxonomy = CreateTaxonomyTable();

            for (int iCnt = 0; iCnt < nodes.Length; iCnt++)
            {
                if (nodes[iCnt].level == level)
                {
                    DataRow row = retTaxonomy.NewRow();
                    row["OID"]         = nodes[iCnt].oid;
                    row["ParentID"]    = oid;
                    row["Description"] = nodes[iCnt].displayName;
                    retTaxonomy.Rows.Add(row);
                }
            }
            // Sort taxonomy on description column
            DataView  dvSortedTaxonomy = new DataView(retTaxonomy, null, "Description", DataViewRowState.CurrentRows);
            DataTable dtSortedTaxonomy = CreateTaxonomyTable();

            for (int iCnt = 0; iCnt < dvSortedTaxonomy.Count; iCnt++)
            {
                DataRow row = dtSortedTaxonomy.NewRow();
                row["OID"]         = dvSortedTaxonomy[iCnt]["OID"];
                row["ParentID"]    = dvSortedTaxonomy[iCnt]["ParentID"];
                row["Description"] = dvSortedTaxonomy[iCnt]["Description"];
                dtSortedTaxonomy.Rows.Add(row);
            }

            if (oid == 0)
            {
                DateTime d          = DateTime.Now;
                DateTime d1         = new DateTime(d.Year, d.Month, d.Day, base.expiration_hrs, base.expiration_min, base.expiration_sec);
                long     expiration = (d1.Ticks - d.Ticks);
                if (expiration < 0)
                {
                    expiration = TimeSpan.TicksPerDay + expiration;
                }
                expiration = expiration / TimeSpan.TicksPerSecond;
                int absoluteExpiration = Convert.ToInt32(expiration);
                int noSliding          = Cache.NoSlidingExpiration.Seconds;

                chTaxonomy.Insert("CSN_KM_TAXONOMY", "Taxonomy_" + oid, dtSortedTaxonomy, null, absoluteExpiration, noSliding);
            }
            else
            {
                CacheDependency cDep = new CacheDependency(null, new string[] { "CSN_KM_TAXONOMY" + ":" + "Taxonomy_0" });
                chTaxonomy.Insert("CSN_KM_TAXONOMY", "Taxonomy_" + oid, dtSortedTaxonomy, cDep);
            }

            return(dtSortedTaxonomy);
        }
예제 #13
0
 public TaxonomyServiceExtension(IRepository <TermContentItem> termContentItemRepository, IContentManager contentManager, INotifier notifier, IContentDefinitionManager contentDefinitionManager, IAuthorizationService authorizationService, IOrchardServices services, IProcessingEngine processingEngine, ShellSettings shellSettings, IShellDescriptorManager shellDescriptorManager, TaxonomyService taxonomyService) : base(termContentItemRepository, contentManager, notifier, contentDefinitionManager, authorizationService, services, processingEngine, shellSettings, shellDescriptorManager)
 {
     _taxonomyService = taxonomyService;
 }