public override bool Update(Taxonomy taxonomy) { if (taxonomy != null && this.CanUpdate(taxonomy)) { try { NpgsqlCommand cmd = Db.GetCmd(Db.ConnectionString); cmd.CommandText = Db.UpdateTaxonomy + Db.SelectById; cmd.Parameters.AddWithValue("name", taxonomy.Name); if (string.IsNullOrEmpty(taxonomy.Description)) { cmd.Parameters.Add(NpgSqlCommandUtils.GetNullInParam("desc", NpgsqlTypes.NpgsqlDbType.Varchar)); } else { cmd.Parameters.AddWithValue("desc", taxonomy.Description); } cmd.Parameters.AddWithValue("id", taxonomy.Identity.Identity); Db.ExecuteNonQuery(cmd); return(true); } catch { } } return(false); }
/// <summary> /// /// </summary> public async Task <PublicJsonResult> CreateAsync(TaxonomyInput input) { //بررسی یکتا بودن عنوان var existTax = await _taxonomyRepository.GetByNameAsync(input.Name.Trim()); if (existTax != null) { return new PublicJsonResult { result = false, message = Messages.Post_Title_Already_Exist } } ; //بررسی نامک -- url friendly input.UrlTitle = input.UrlTitle.IsNullOrEmptyOrWhiteSpace() ? input.Name.GenerateUrlTitle() : input.UrlTitle.GenerateUrlTitle(); var post = new Taxonomy { Id = input.Id, Name = input.Name, Description = input.Description, PostCount = input.PostCount, Type = input.Type, UrlTitle = input.UrlTitle, }; await _taxonomyRepository.CreateAsync(post); return(new PublicJsonResult { result = true, id = post.Id, message = Messages.Post_Create_Success }); }
public string GetString(Taxonomy taxonomy, string pad = "") { var sb = new StringBuilder(); sb.AppendLine(pad + this.GetType().Name + " " + this.ID); if (DictFilterIndexes.Count > 0) { sb.Append(pad); foreach (var ix in DictFilterIndexes) { sb.Append(taxonomy.CounterFactParts[ix] + ", "); } sb.AppendLine(""); } if (NegativeDictFilterIndexes.Count > 0) { sb.Append(pad + "! "); foreach (var ix in NegativeDictFilterIndexes) { sb.Append(taxonomy.CounterFactParts[ix] + ", "); } sb.AppendLine(""); } foreach (var child in ChildQueries) { sb.AppendLine(child.GetString(taxonomy, Literals.Tab + pad)); } return(sb.ToString()); }
public override Taxonomy Get(CompoundIdentity id) { if (!id.IsNullOrEmpty() && this.CanGet()) { NpgsqlCommand cmd = Db.GetCmd(Db.ConnectionString); cmd.CommandText = Db.SelectTaxonomy + Db.SelectTaxonomyById; cmd.Parameters.AddWithValue("id", id.Identity); NpgsqlDataReader rdr = Db.ExecuteReader(cmd); Taxonomy t = null; if (rdr != null) { try { rdr.Read(); t = TaxonomyBuilder.Instance.Build(rdr); if (cmd.Connection.State == System.Data.ConnectionState.Open) { cmd.Connection.Close(); } } catch { } finally { cmd.Dispose(); } } return(t); } return(null); }
public TaxonomyDomain PatchTaxonomy(int id, Taxonomy taxonomy) { try { var taxonomyEntity = Context.Taxonomies .Include(o => o.ServiceTaxonomies) .FirstOrDefault(o => o.Id == id); if (taxonomy == null) { throw new InvalidOperationException("Taxonomy does not exist"); } taxonomyEntity.Name = taxonomy.Name; taxonomyEntity.Description = taxonomy.Description; taxonomyEntity.Vocabulary = taxonomy.Vocabulary; taxonomyEntity.Weight = taxonomy.Weight; Context.SaveChanges(); return(_mapper.ToDomain(taxonomyEntity)); } catch (DbUpdateException dbe) { HandleDbUpdateException(dbe); } catch (Exception e) { LoggingHandler.LogError(e.Message); LoggingHandler.LogError(e.StackTrace); throw; } return(null); }
public IList <int> ToList(Taxonomy taxonomy, IList <int> facts, bool ensurepartnr = false) { //cover here var partnr = Cover ? ensurepartnr ? NrOfDictFilters : 0 : 0; var items = taxonomy.SearchFactsGetIndex3(DictFilterIndexes.ToArray(), taxonomy.FactsOfParts, facts, partnr); foreach (var negativeindex in NegativeDictFilterIndexes) { if (taxonomy.FactsOfParts.ContainsKey(negativeindex)) { items = Utilities.Objects.SortedExcept(items, taxonomy.FactsOfParts[negativeindex]); } } if (ChildQueries.Count > 0) { var result = new List <int>(); foreach (var childquery in ChildQueries) { result.AddRange(childquery.ToList(taxonomy, items)); } return(result); } return(items); }
/// <summary> /// </summary> protected INodesForIndexingProvider GetNodeProvider() { Taxonomy tax = ParseTaxonomy(GetTaxonomyPath()); tax.CurrentLabelRole = "preferredLabel"; return(new DeepTaxonomyNodeFinder(TaxonomyView.Presentation(tax))); }
/// <summary> /// Get the top-level categories for the given taxonomy. Note that this /// does not return all the categories for a taxonomy. /// </summary> /// <param name="taxonomy">The taxonomy of categories</param> /// <returns>A list of Category objects</returns> /// <exception cref="Terra.ServerException">The given taxonomy does not exist</exception> public List<Category> Children(Taxonomy taxonomy) { return _client.Request("taxonomy/categories"). AddParameter("opco", taxonomy.Opco). AddParameter("slug", taxonomy.Slug). MakeRequest<List<Category>>(); }
public void DeleteTaxonomy(long taxonomyId) { Taxonomy Taxonomy = GetTaxonomy(taxonomyId); DataContext.Taxonomies.Remove(Taxonomy); DataContext.SaveChanges(); }
public async stt::Task ReplaceTaxonomyRequestObjectAsync() { moq::Mock <PolicyTagManagerSerialization.PolicyTagManagerSerializationClient> mockGrpcClient = new moq::Mock <PolicyTagManagerSerialization.PolicyTagManagerSerializationClient>(moq::MockBehavior.Strict); ReplaceTaxonomyRequest request = new ReplaceTaxonomyRequest { TaxonomyName = TaxonomyName.FromProjectLocationTaxonomy("[PROJECT]", "[LOCATION]", "[TAXONOMY]"), SerializedTaxonomy = new SerializedTaxonomy(), }; Taxonomy expectedResponse = new Taxonomy { TaxonomyName = TaxonomyName.FromProjectLocationTaxonomy("[PROJECT]", "[LOCATION]", "[TAXONOMY]"), DisplayName = "display_name137f65c2", Description = "description2cf9da67", PolicyTagCount = -1730676159, TaxonomyTimestamps = new SystemTimestamps(), ActivatedPolicyTypes = { Taxonomy.Types.PolicyType.Unspecified, }, }; mockGrpcClient.Setup(x => x.ReplaceTaxonomyAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Taxonomy>(stt::Task.FromResult(expectedResponse), null, null, null, null)); PolicyTagManagerSerializationClient client = new PolicyTagManagerSerializationClientImpl(mockGrpcClient.Object, null); Taxonomy responseCallSettings = await client.ReplaceTaxonomyAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); Taxonomy responseCancellationToken = await client.ReplaceTaxonomyAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void UpdateItemCategory(Taxonomy taxonomy) { DataContext.Taxonomies.Attach(taxonomy); DataContext.Entry(taxonomy).State = EntityState.Modified; SetAuditFields(taxonomy); DataContext.SaveChanges(); }
public IEnumerable <IValidationIssue> ApplyIfValid( RootModel model, Taxonomy taxonomy, RepositoryManager repositoryManager, String username, String userEmail, SqlConnection connection, SecurityRepository securityRepository, BasketRepository basketRepository, PortfolioRepository portfolioRepository, CalculationTicket ticket, ref CalculationInfo info ) { var issues = this.ValidateModelAndPermissions(model, username, ticket); var traverser = new IssueTraverser(); var traversedIssues = traverser.TraverseAll(issues); if (traversedIssues.Any(x => x is ErrorIssue)) { return(issues); } try { this.Apply(model, taxonomy, repositoryManager, username, userEmail, connection, securityRepository, basketRepository, portfolioRepository, ref info); return(issues); } catch (ValidationException exception) { return(issues.Union(new IValidationIssue[] { exception.Issue })); } }
public void Persist() { var taxonomy = new Taxonomy <char>( new Dictionary <char, IList <char> > { { 'A', new char[] {} }, { 'B', new char[] {} }, { 'C', new char[] { 'B' } }, { 'D', new char[] { 'B' } }, }); using (var scope = _container.BeginLifetimeScope()) { var session = scope.Resolve <ISession>(); session.Save(taxonomy); taxonomy.Visit(term => session.Save(term)); session.Flush(); } using (var scope = _container.BeginLifetimeScope()) { var session = scope.Resolve <ISession>(); taxonomy = session.Get <Taxonomy <char> >(taxonomy.Id); Assert.That(taxonomy, Is.Not.Null); Assert.That(taxonomy['B'].Contains(taxonomy['C']), Is.True); } }
public static void SetCells(Taxonomy taxonomy, List <ValidationRuleResult> results) { foreach (var result in results) { SetCells(taxonomy, result); } }
public static void ExecuteImplicitFiltering(Taxonomy taxonomy, ValidationRule rule) { var dict = new Dictionary <int, int[]>(); var uncoveredmainaspects = GetUncoveredDomains(taxonomy, dict, rule); GroupTaxFacts(taxonomy, dict, rule, uncoveredmainaspects); }
/// <summary> /// This is our last chance to manipulate the page. All we want to do is see if our category browser is going to /// show any taxonomies. If it isn't, we'll output a message instead of an empty control. /// </summary> /// <param name="args"></param> protected override void OnPreRender(EventArgs args) { // // If we are not in a postback, and there are no taxonomies being shown, // display a message // if (0 == uddi_categoryBrowser.TaxonomyCount && !IsPostBack) { aspnet_noCategoriesMessage.Text = Localization.GetString("AWR_NO_CATEGORIES"); aspnet_noCategoriesMessage.Visible = true; uddi_categoryBrowser.Visible = false; } // // Only enable our search button if we are looking at a categorization scheme that is // valid for categorization. // string taxonomyID = uddi_categoryBrowser.TaxonomyID; string tModelKey = uddi_categoryBrowser.TModelKey; string keyValue = uddi_categoryBrowser.KeyValue; if (null != taxonomyID && taxonomyID.Length > 0 && null != keyValue && keyValue.Length > 0 && Taxonomy.IsValidForClassification(Convert.ToInt32(taxonomyID), keyValue)) { aspnet_searchFromBrowse.Enabled = true; } else { aspnet_searchFromBrowse.Enabled = false; } base.OnPreRender(args); }
private Linkbase CreateLabelLinkbase(Taxonomy taxonomy, DiscoverableTaxonomySet dts) { var linkbase = new Linkbase(GetLinkbaseFileName(taxonomy, "lab")); var labelLink = new LabelLink(LinkbaseXNames.Label, LinkRoles.Generic); linkbase.AddLink(labelLink, dts); var locCount = 0; var labCount = 0; foreach (var extensionItem in ExtensionItems) { var locLabel = $"loc{locCount}"; locCount += 1; var locNode = CreateLocatorNode(locLabel, extensionItem, dts); labelLink.AddNode(locNode); foreach (var extensionLabel in extensionItem.Labels) { var labLabel = $"lab{labCount}"; labCount += 1; var labNode = new LabelNode(labLabel, extensionLabel.Role, extensionLabel.Text, extensionLabel.Language); labelLink.AddNode(labNode); var arc = new LabelArc(locNode, labNode); labelLink.AddArc(arc); } } return(linkbase); }
public async Task SeedAsync(DbContext context) { var entityTypeSet = context.Set <TaxonomyType>(); var desingTheme = await entityTypeSet.FirstOrDefaultAsync(o => o.Name == HouseStyle.Name); if (desingTheme == null) { HouseStyle = entityTypeSet.Add(HouseStyle).Entity; } else { HouseStyle = desingTheme; } Apartment.TaxonomyTypeId = HouseStyle.Id; LandedHouse.TaxonomyTypeId = HouseStyle.Id; var taxonomySet = context.Set <Taxonomy>(); Apartment = await SeedEntityAsync(taxonomySet, Apartment); LandedHouse = await SeedEntityAsync(taxonomySet, LandedHouse); await context.SaveChangesAsync(); }
/// <summary> /// /// </summary> public async Task UpdateAsync(Taxonomy tax) { await _taxonomies.ReplaceOneAsync(t => t.Id == tax.Id, tax, new UpdateOptions() { IsUpsert = false }); }
public static TaxonomyData createTaxonomyTree(long TaxonomyId) { TaxonomyRequest taxonomyRequest = new TaxonomyRequest(); Ektron.Cms.API.Content.Taxonomy tax1 = new Taxonomy(); // Ektron.Cms.TaxonomyData taxData = new TaxonomyData(); try { taxonomyRequest.TaxonomyId = TaxonomyId; // taxonomyRequest.Page = Page; taxonomyRequest.TaxonomyLanguage = 1033; // taxonomyRequest.PageSize = contentApi.RequestInformationRef.PagingSize; taxonomyRequest.Depth = -1; taxonomyRequest.ReadCount = true; taxonomyRequest.TaxonomyType = 0; //0 = content; 1 = user; 2 = group; taxonomyRequest.IncludeItems = false; // taxonomyRequest.SortOrder = "last_edit_date"; // taxonomyRequest.SortDirection = "desc"; taxData = tax1.LoadTaxonomy(ref taxonomyRequest); TaxonomyBaseData[] taxonomyDataArray = new CommonApi().EkContentRef.ReadAllSubCategories(taxonomyRequest); } catch (Exception) { } return taxData; }
public void ReplaceTaxonomyRequestObject() { moq::Mock <PolicyTagManagerSerialization.PolicyTagManagerSerializationClient> mockGrpcClient = new moq::Mock <PolicyTagManagerSerialization.PolicyTagManagerSerializationClient>(moq::MockBehavior.Strict); ReplaceTaxonomyRequest request = new ReplaceTaxonomyRequest { TaxonomyName = TaxonomyName.FromProjectLocationTaxonomy("[PROJECT]", "[LOCATION]", "[TAXONOMY]"), SerializedTaxonomy = new SerializedTaxonomy(), }; Taxonomy expectedResponse = new Taxonomy { TaxonomyName = TaxonomyName.FromProjectLocationTaxonomy("[PROJECT]", "[LOCATION]", "[TAXONOMY]"), DisplayName = "display_name137f65c2", Description = "description2cf9da67", PolicyTagCount = -1730676159, TaxonomyTimestamps = new SystemTimestamps(), ActivatedPolicyTypes = { Taxonomy.Types.PolicyType.Unspecified, }, }; mockGrpcClient.Setup(x => x.ReplaceTaxonomy(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); PolicyTagManagerSerializationClient client = new PolicyTagManagerSerializationClientImpl(mockGrpcClient.Object, null); Taxonomy response = client.ReplaceTaxonomy(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
protected string GenerateRootTreeHtml(string controlId, int languageID, List<long> rootTaxonomyIds) { if (rootTaxonomyIds.Count == 0) return ""; Taxonomy taxonomyAPI = new Taxonomy(); TaxonomyRequest taxonomyRequest = new TaxonomyRequest(); taxonomyRequest.TaxonomyId = 0; taxonomyRequest.TaxonomyLanguage = languageID; StringBuilder sb = new StringBuilder(); sb.Append("<ul>"); TaxonomyData taxonomyData = taxonomyAPI.LoadTaxonomy(ref taxonomyRequest); if (taxonomyData != null) { foreach (TaxonomyData childTaxonomyData in taxonomyData.Taxonomy) { if (rootTaxonomyIds.Contains(childTaxonomyData.TaxonomyId)) { sb.Append(GenerateCategoryHtml(controlId, languageID, childTaxonomyData.TaxonomyId)); } } } sb.Append("</ul>"); return sb.ToString(); }
public void TestValidateTaxonomyRecursively() { Taxonomy tx = new Taxonomy(); int errors = 0; DateTime start = DateTime.Now; Assert.AreEqual(true, tx.Load(US_GAAP_FILE, out errors), "Could not load US GAAP File"); Assert.AreEqual(0, errors); Console.WriteLine("=========================="); ValidationStatus VS = tx.Validate(); Console.WriteLine("Number of Errros: " + tx.ValidationErrors.Count); Console.WriteLine("Number of Warnings: " + tx.ValidationWarnings.Count); Console.WriteLine("Validation Status: " + VS.ToString()); if (tx.ValidationWarnings.Count > 0) { System.Collections.IEnumerator vwarnings = tx.ValidationWarnings.GetEnumerator(); while (vwarnings.MoveNext()) { Console.WriteLine(" Warning > " + vwarnings.Current); } } if (tx.ValidationErrors.Count > 0) { System.Collections.IEnumerator verrors = tx.ValidationErrors.GetEnumerator(); while (verrors.MoveNext()) { Console.WriteLine(" Error > " + verrors.Current); } } Console.WriteLine("=========================="); }
public void TestUkCompanies_Instances() { Taxonomy tax = new Taxonomy(); int errors = 0; DateTime start = DateTime.Now; if (tax.Load(COMPANIES_HOUSE_FILE, out errors) != true) { Assert.Fail((string)tax.ErrorList[0]); } errors = 0; // this loads up all dependant taxonomies, and loads the corresponding presentation, calculation, label, and reference linkbases // parse presentation first tax.CurrentLabelRole = "preferredLabel"; tax.CurrentLanguage = "en"; tax.Parse(out errors); Assert.AreEqual(0, errors, "should not have any errors"); Hashtable prefixXRef = new Hashtable(); prefixXRef["ae"] = "uk-gaap-ae"; prefixXRef["pt"] = "uk-gaap-pt"; prefixXRef["gc"] = "uk-gcd"; ValidateInstanceDoc(tax, DAMC_INST_FILE, 0, prefixXRef); ValidateInstanceDoc(tax, DAMC_INST_FILE_Missing_Item, 2, prefixXRef); ValidateInstanceDoc(tax, DAM_INST_FILE, 0, prefixXRef); ValidateInstanceDoc(tax, DAM_INST_FILE_Missing_Item, 1, prefixXRef); }
public FileEntry(TaxonomyLib.File file, string path, Taxonomy taxonomy) { this.file = file; Path = path; IsDirectory = Directory.Exists(path); this.taxonomy = new WeakReference <Taxonomy>(taxonomy); }
/// <summary> /// Creates a new taxonomy /// </summary> /// <param name="termId">Id of the term associated with the taxonomy</param> /// <param name="name">Name of the taxonomy</param> /// <param name="description">Description of the taxonomy</param> /// <returns>Newly created taxonomy object</returns> public Taxonomy CreateTaxonomy(int termId, string name, string description = "") { if (termId == 0) { throw new ArgumentException("Term Id cannot be zero.", nameof(termId)); } var term = _termRepository.GetById(termId); if (term == null) { throw new ArgumentException($"No term found for the specified id = {termId}", nameof(term)); } var taxonomy = new Taxonomy() { TermId = termId, Name = name, Description = description, Count = 1 }; _taxonomyRepository.Create(taxonomy); return(taxonomy); }
public void Adds_Taxonomies_To_Where() { // Arrange var(builder, v) = Setup(); var t0 = new Taxonomy(Rnd.Str); var t1 = new Taxonomy(Rnd.Str); var taxonomies = ImmutableList.Create(t0, t1); // Act var result = builder.AddWhereTaxonomies(v.Parts, taxonomies); // Assert var some = result.AssertSome(); Assert.NotSame(v.Parts, some); Assert.Collection(some.Where, x => { Assert.Equal(builder.TTest.TermTaxonomies.GetName(), x.column.TblName); Assert.Equal(builder.TTest.TermTaxonomies.Taxonomy, x.column.ColName); Assert.Equal(Compare.In, x.compare); Assert.Equal(taxonomies, x.value); } ); }
public ListTaxodesc(MainForm parent_form, Glacc current_acc, List <Taxonomy> list_taxonomy, Taxonomy current_taxonomy = null) { InitializeComponent(); this.current_acc = current_acc; this.current_taxonomy = current_taxonomy; this.list_taxonomy = list_taxonomy; }
private void ValidateInstanceDoc(Taxonomy tax, string fileName, int countErrors, Hashtable prefixXRef) { Instance ins = new Instance(); ArrayList errs; if (!ins.TryLoadInstanceDoc(fileName, out errs)) { Assert.Fail("Failed to load instance document" + fileName); } foreach (MarkupProperty mp in ins.markups) { if (prefixXRef[mp.elementPrefix] != null) { string realPrefix = prefixXRef[mp.elementPrefix] as string; mp.elementPrefix = realPrefix; mp.elementId = string.Format(DocumentBase.ID_FORMAT, mp.elementPrefix, mp.elementName); } } string[] validationErrors; tax.ValidateInstanceInformationForRequiresElementCheck(ins, out validationErrors); Assert.IsNotNull(validationErrors, "Validation errors object should not be null"); foreach (string str in validationErrors) { Console.WriteLine(str); } Assert.AreEqual(countErrors, validationErrors.Length, "Failed to ValidateInstanceInformationForRequiresElementCheck"); }
public void TestSaveToLocalApplicationData() { string fileName = AucentGeneral.RivetApplicationDataDragonTagPath + System.IO.Path.DirectorySeparatorChar + "us-gaap-ci-2005-02-28.xsd"; if (File.Exists(fileName)) { File.Delete(fileName); } fileName = AucentGeneral.RivetApplicationDataDragonTagPath + System.IO.Path.DirectorySeparatorChar + "usfr-ptr-2005-02-28.xsd"; if (File.Exists(fileName)) { File.Delete(fileName); } Taxonomy tx = new Taxonomy(); int errors = 0; DateTime start = DateTime.Now; Assert.AreEqual(true, tx.Load("http://www.xbrl.org/us/fr/gaap/ci/2005-02-28/us-gaap-ci-2005-02-28.xsd", out errors), "Could not load US GAAP File"); Assert.AreEqual(0, errors); tx.Parse(out errors); DateTime end = DateTime.Now; Console.WriteLine("Parse Time: {0}", end - start); fileName = AucentGeneral.RivetApplicationDataDragonTagPath + System.IO.Path.DirectorySeparatorChar + "us-gaap-ci-2005-02-28.xsd"; Assert.IsTrue(File.Exists(fileName)); fileName = AucentGeneral.RivetApplicationDataDragonTagPath + System.IO.Path.DirectorySeparatorChar + "usfr-ptr-2005-02-28.xsd"; Assert.IsTrue(File.Exists(fileName)); }
/// <summary> /// Register custom taxonomies /// </summary> public override void RegisterCustomTaxonomies() { Taxonomy.AddCustomTaxonomy(Taxonomies.BibleBook); Taxonomy.AddCustomTaxonomy(Taxonomies.PlacePreached); Taxonomy.AddCustomTaxonomy(Taxonomies.Section); Taxonomy.AddCustomTaxonomy(Taxonomies.Series); Taxonomy.AddCustomTaxonomy(Taxonomies.Theme); }
private string TryGetRankName(string rankType) { if (Taxonomy.Any(x => x.Type == rankType)) { return(Taxonomy.Single(x => x.Type == rankType).Name); } return(string.Empty); }
public async Task <IActionResult> AddTaxonomy(Taxonomy taxonomy) { return(Ok(taxonomy)); await _dbContext.Taxonomy.AddAsync(taxonomy); await _dbContext.SaveChangesAsync(); return(Ok()); }
protected string GenerateCategoryHtml(string controlId, int languageID, long taxonomyId) { StringBuilder sb = new StringBuilder(); Taxonomy taxonomyAPI = new Taxonomy(); TaxonomyRequest taxonomyRequest = new TaxonomyRequest(); taxonomyRequest.TaxonomyId = taxonomyId; taxonomyRequest.TaxonomyLanguage = languageID; TaxonomyData taxonomyData = taxonomyAPI.LoadTaxonomy(ref taxonomyRequest); SiteAPI siteAPI = new SiteAPI(); sb.Append("<li id=\"ekTaxonomy"); sb.Append(controlId); sb.Append("_"); sb.Append(taxonomyId.ToString()); sb.Append("\">"); if (taxonomyData.Taxonomy.Length > 0) { sb.Append("<a href=\"#\" onclick=\"toggleTree('"); sb.Append(controlId); sb.Append("', "); sb.Append(taxonomyId.ToString()); sb.Append(");\"><img id=\"ekIMG"); sb.Append(controlId); sb.Append("_"); sb.Append(taxonomyId.ToString()); sb.Append("\" src=\""); sb.Append(siteAPI.SitePath); sb.Append("Workarea/images/ui/icons/tree/taxonomyCollapsed.png\" border=\"0\"></img></a>"); } else { sb.Append("<img src=\""); sb.Append(siteAPI.SitePath); sb.Append("Workarea/images/ui/icons/tree/taxonomy.png\"></img>"); } sb.Append("<input type=\"checkbox\" id=\""); sb.Append("ekCheck"); sb.Append(controlId); sb.Append("_"); sb.Append(taxonomyId.ToString()); sb.Append("\" onclick=\"selectCategory(this);\">"); sb.Append(taxonomyData.TaxonomyName); return sb.ToString(); }
/// <summary> /// </summary> public static Taxonomy ParseTaxonomy(string pathFragment) { Taxonomy IMTaxonomy = new Taxonomy(); string path = _TestTaxonomiesDirectory + "\\" + pathFragment; if (File.Exists(path)) { int errors; IMTaxonomy.Load(path); IMTaxonomy.Parse(out errors); IMTaxonomy.CurrentLanguage = "en"; IMTaxonomy.CurrentLabelRole = "label"; return IMTaxonomy; } return null; }
/// <summary> /// Remove a property from a taxonomy. Note that this does not remove /// any of the relations between options and this node. It does, /// however, filter the options from any requests that use the properties /// associated with the node as a filter, such as inheritance. /// </summary> /// <param name="taxonomy">The taxonomy from which to remove the property</param> /// <param name="property">The property to remove</param> /// <exception cref="Terra.ServerException">Either the property or the taxonomy doesn't exist</exception> public void RemoveProperty(Taxonomy taxonomy, Property property) { _client.Request("taxonomy/property", Method.DELETE). AddParameter("opco", taxonomy.Opco). AddParameter("taxonomy", taxonomy.Slug). AddParameter("property", property.Slug). MakeRequest(); }
/// <summary> /// Look up the properties associated with the given taxonomy. The list /// returned does not include options, and there may be properties in /// the list that have no options associated with them anyway. /// </summary> /// <param name="taxonomy">The taxonomy with which the properties are associated</param> /// <returns>A list of Property objects</returns> /// <exception cref="Terra.ServerException">The taxonomy does not exist</exception> public List<Property> Properties(Taxonomy taxonomy) { return _client.Request("taxonomy/properties"). AddParameter("opco", taxonomy.Opco). AddParameter("slug", taxonomy.Slug). MakeRequest<List<Property>>(); }
/// <summary> /// Get the top-level categories for the given taxonomy. Note that this /// does not return all the categories for a taxonomy. /// /// This is the same call present in the Terra.Service.Categories class. /// It is here as a convenience. /// </summary> /// <seealso cref="Terra.Service.Categories.Children(Terra.Category)"/> /// <param name="taxonomy">The taxonomy of categories</param> /// <returns>A list of Category objects</returns> /// <exception cref="Terra.ServerException">The given taxonomy does not exist</exception> public List<Category> Children(Taxonomy taxonomy) { return _client.Categories.Children(taxonomy); }
/// <summary> /// Remove the synonym with from the taxonomy. Note that this doesn't /// delete the synonym, simply removes its association from this /// taxonomy. /// </summary> /// <param name="taxonomy">The taxonomy with which to disassociate the synonym</param> /// <param name="synonym">The synonym for the taxonomy</param> /// <exception cref="Terra.ServerException">Either the taxonomy or the synonym doesn't exist</exception> public void RemoveSynonym(Taxonomy taxonomy, Synonym synonym) { _client.Request("taxonomy/synonym", Method.DELETE). AddParameter("opco", taxonomy.Opco). AddParameter("taxonomy", taxonomy.Slug). AddParameter("slug", synonym.Slug). MakeRequest(); }
/// <summary> /// This is a convenience method to create or add an existing synonym /// (or translation) to a taxonomy. If the synonym does not already /// exist, it is created with a default slug (and default language, if /// not otherwise indicated). The synonym, existing or new, is /// associated with the taxonomy. /// </summary> /// <param name="taxonomy">The taxonomy to associate with this synonym</param> /// <param name="synonym">The new or existing name of a synonym</param> /// <param name="language">The language of the synonym; defaults to the opco's language</param> /// <returns>The new or existing synonym</returns> /// <exception cref="Terra.ServerException">The taxonomy does not exist</exception> public Synonym AddSynonym(Taxonomy taxonomy, string synonym, string language = null) { var slug = _client.Slugify(synonym); try { var existing = _client.Synonyms.Get(taxonomy.Opco, slug); _client.Request("taxonomy/synonym", Method.PUT). AddParameter("opco", taxonomy.Opco). AddParameter("taxonomy", taxonomy.Slug). AddParameter("slug", slug). MakeRequest(); return existing; } catch (ServerException e) { if (e.Status == System.Net.HttpStatusCode.NotFound) { return CreateSynonym(taxonomy, synonym, slug, language); } else { throw e; } } }
/// <summary> /// </summary> public ElementTaxonomyView(Taxonomy _taxonomy) : base(_taxonomy) { }
/// <summary> /// Remove an option from a taxonomy. The taxonomy, option, and property /// must all exist in the same operating company. /// </summary> /// <param name="taxonomy">The taxonomy from which to remove the option</param> /// <param name="property">The property or "verb" used in the relation</param> /// <param name="option">The option being removed</param> /// <exception cref="Terra.ServerException">Either the option, property or the taxonomy doesn't exist</exception> public void RemoveOption(Taxonomy taxonomy, Property property, Option option) { _client.Request("taxonomy/option", Method.DELETE). AddParameter("opco", taxonomy.Opco). AddParameter("taxonomy", taxonomy.Slug). AddParameter("property", property.Slug). AddParameter("option", option.Slug). MakeRequest(); }
/// <summary> /// Completely deletes the given taxonomy from the Terra server. If /// there are any categories associated with the taxonomy, they are /// orphaned, as are any properties and options associated with the /// taxonomy. /// /// This method returns nothing. If the delete is unsuccessful, an /// exception will be raised. Otherwise it completed successfully. /// </summary> /// <param name="taxonomy">The taxonomy to delete; only Opco and Slug are used</param> /// <exception cref="Terra.ServerException"> /// Raises a Not Found exception if the taxonomy does not exist, or /// a Precondition Failed if the taxonomy on the server is newer than /// the one submitted. /// </exception> public void Delete(Taxonomy taxonomy) { _client.Request("taxonomy", Method.DELETE). AddParameter("opco", taxonomy.Opco). AddParameter("slug", taxonomy.Slug). AddParameter("v", taxonomy.Version). MakeRequest(); }
/// <summary> /// Update's the name and language of the given Taxonomy with the server. /// Will not change the slug or operating company however. If you modify /// either of those, mostly likely you will receive a Not Found status in /// the ServerException, indicating the Taxonomy object could not be found /// on the Terra server. /// /// Note that this method will return a new Taxonomy object. The original /// object will not be modified. /// </summary> /// <param name="taxonomy">An existing taxonomy with its name or language modified</param> /// <returns>A new Taxonomy object with the updated information, as confirmation</returns> /// <exception cref="Terra.ServerException"> /// <list type="bullet"> /// <item> /// <description>If any of the parameters submitted are invalid, returns a status of Not Acceptable.</description> /// </item> /// <item> /// <description>If the existing taxonomy could not be found on the server, returns a status of Not Found</description> /// </item> /// <item> /// <description>If the local taxonomy is older than the version on the server, a Precondition Failed status is returned</description> /// </item> /// </list> /// </exception> public Taxonomy Update(Taxonomy taxonomy) { return _client.Request("taxonomy", Method.PUT). AddParameter("opco", taxonomy.Opco). AddParameter("name", taxonomy.Name). AddParameter("slug", taxonomy.Slug). AddParameter("lang", taxonomy.Language). AddParameter("v", taxonomy.Version). MakeRequest<Taxonomy>(); }
/// <summary> /// Initializes a new instance of the <see cref="TaxonParamResolver"/> class. /// </summary> /// <param name="taxonomyName">Name of the taxonomy where the taxon will be expected.</param> /// <exception cref="System.ArgumentException">When taxonomy with the given name is not found.</exception> public TaxonParamResolver(string taxonomyName) { this.taxonomy = TaxonomyManager.GetManager().GetTaxonomies<Taxonomy>().FirstOrDefault(t => t.Name == taxonomyName); if (this.taxonomy == null) throw new ArgumentException("Taxonomy with name {0} was not found!".Arrange(taxonomyName)); }
/// <summary> /// </summary> protected TaxonomyView(Taxonomy _taxonomy) { this._taxonomy = _taxonomy; }
public static ArrayList GetAssignedTaxonomyArray(long contentId) { ArrayList AssignedTaxonomyList = new ArrayList(); Taxonomy taxonomyApi = new Taxonomy(); TaxonomyBaseData[] taxBaseData = taxonomyApi.ReadAllAssignedCategory(contentId); if (taxBaseData.Length > 0) { foreach (TaxonomyBaseData txbd in taxBaseData) { AssignedTaxonomyList.Add(txbd.Id.ToString()); } //long taxonomyid = taxBaseData[0].TaxonomyId; } return AssignedTaxonomyList; }
/// <summary> /// Find all the options directly associated with this taxonomy. /// /// This operation can be a bit slow, as the system has to filter and /// collate options and properties. It is typically faster to request /// a list of properties, then request the options for a selected /// property (this is how the Terra UI does things). Of course by /// "slow", we mean takes around 300ms. /// </summary> /// <param name="taxonomy">The taxonomy of options to retrieve</param> /// <returns>A list of Property objects with their Options list filled</returns> /// <exception cref="Terra.ServerException">The taxonomy doesn't exist</exception> public List<Property> Options(Taxonomy taxonomy) { return _client.Request("taxonomy/options"). AddParameter("opco", taxonomy.Opco). AddParameter("slug", taxonomy.Slug). GenericRequest().ConvertAll<Property>(node => (Property) node);; }
/// <summary> /// Get the list of synonyms associated with this taxonomy. /// </summary> /// <param name="taxonomy">The taxonomy</param> /// <returns>A list of synonyms</returns> /// <exception cref="Terra.ServerException">The taxonomy does not exist</exception> public List<Synonym> Synonyms(Taxonomy taxonomy) { return _client.Request("taxonomy/synonyms"). AddParameter("opco", taxonomy.Opco). AddParameter("slug", taxonomy.Slug). MakeRequest<List<Synonym>>(); }
/// <summary> /// Find all the options directly associated with this category by the /// given property. /// </summary> /// <param name="taxonomy">The taxonomy of options to retrieve</param> /// <param name="property">The property to limit the options by</param> /// <returns>A list of the Options associated with the taxonomy via the property</returns> public List<Option> Options(Taxonomy taxonomy, Property property) { return _client.Request("taxonomy/options"). AddParameter("opco", taxonomy.Opco). AddParameter("slug", taxonomy.Slug). AddParameter("property", property.Slug). MakeRequest<List<Option>>(); }
/// <summary> /// Create a new synonym and associate it with this taxonomy. /// /// Synonyms may also be used as a simple translation tool. When you /// create a synonym, by default it is assigned to the same langauge as /// the operating company. However, by assigning a different language /// to the synonym, you now have a translation for the taxonomy. /// </summary> /// <param name="taxonomy">The taxonomy to associate with the synonym</param> /// <param name="name">The human-readable name of the synonym</param> /// <param name="slug">An SEO-compliant slug for the synonym; generated if not provided</param> /// <param name="language">The language of the name; defaults to the opco's language</param> /// <returns>The newly created Synonym</returns> /// <exception cref="Terra.ServerException">The taxonomy does not exist, or the synonym already exists</exception> public Synonym CreateSynonym(Taxonomy taxonomy, string name, string slug = null, string language = null) { return _client.Request("taxonomy/synonym", Method.POST). AddParameter("opco", taxonomy.Opco). AddParameter("name", name). AddParameter("slug", slug). AddParameter("lang", language). AddParameter("taxonomy", taxonomy.Slug). MakeRequest<Synonym>(); }
///<summary> ///</summary> public static TaxonomyView Calculation(Taxonomy t) { return new CalculationTaxonomyView(t); }
/// <summary> /// </summary> public PresentationTaxonomyView(Taxonomy _taxonomy) : base(_taxonomy) { }
protected string GenerateTreeHtml(string controlId, int languageID, long taxonomyId) { string taxonomyHtml; StringBuilder sb = new StringBuilder(); ContentAPI contentAPI = new Ektron.Cms.ContentAPI(); TaxonomyRequest taxonomyRequest = new TaxonomyRequest(); taxonomyRequest.TaxonomyId = taxonomyId; taxonomyRequest.TaxonomyLanguage = languageID; Taxonomy taxonomyAPI = new Taxonomy(); TaxonomyData taxonomyData = taxonomyAPI.LoadTaxonomy(ref taxonomyRequest); if (taxonomyData.Taxonomy.Length == 0) return ""; sb.Append("<ul>"); foreach (TaxonomyData childTaxonomyData in taxonomyData.Taxonomy) { taxonomyHtml = GenerateCategoryHtml(controlId, languageID, childTaxonomyData.TaxonomyId); sb.Append(taxonomyHtml); } sb.Append("</ul>"); return sb.ToString(); }
///<summary> ///</summary> public static TaxonomyView Element(Taxonomy t) { return new ElementTaxonomyView(t); }
public static string GetAssignedTaxonomyList(long contentId) { string AssignedTaxonomyList = ""; Taxonomy taxonomyApi = new Taxonomy(); TaxonomyBaseData[] taxBaseData = taxonomyApi.ReadAllAssignedCategory(contentId); if (taxBaseData.Length > 0) { int p = 0; foreach (TaxonomyBaseData txbd in taxBaseData) { if (p >= 1) { AssignedTaxonomyList += ","; } AssignedTaxonomyList += txbd.Id.ToString(); p++; } //long taxonomyid = taxBaseData[0].TaxonomyId; return AssignedTaxonomyList; } else { return ""; } }
///<summary> ///</summary> public static TaxonomyView Presentation(Taxonomy t) { return new PresentationTaxonomyView(t); }
protected void Page_Load(object sender, EventArgs e) { contentAPI = new Ektron.Cms.ContentAPI(); taxonomyAPI = new Taxonomy(); siteAPI = new SiteAPI(); AddScriptBlocksToHeader(); FillTaxonomyTree(); }
/// <summary> /// </summary> public CalculationTaxonomyView(Taxonomy _taxonomy) : base(_taxonomy) { }