Alfresco: Restrict categories that can be selected - alfresco

I have a custom content type in Alfresco (3.3 Enterprise, if it matters) and I can assign one or more categories to that content. So far so good.
But can I restrict the set of possible categories to only a subset of all categories? If, for example, categories looked like below, how can I restrict the user to only selecting a region subcategory (e.g. Europe, South America, etc).
Categories
+ Software Document Classification <- I do not want these to be picked.
| + Utilisation Documents
| + Software Descriptions
| + ...
|
+ Regions <- I want to restrict the
| + Latin America user to this subset of categories.
| + Europe
| + ...
+ ...
Is this possible?

You can set the category root where users may start from via the "parentNodeRef" control-param on the category.ftl control. Simply find out the NodeRef for the category you wan to start from (the "Regions" node) and use that value for the "parentNodeRef" control-param.
Please see https://forums.alfresco.com/forum/developer-discussions/alfresco-share-development/change-root-element-category-picker-control for a similar question and the original answer. Also see https://wiki.alfresco.com/wiki/Forms#category.ftl for an overview over the most important control-params for category.ftl.

Related

product variant price view table query

I have question need to query from product table and have many variants and prices, how can I show like below
product. variants. price
==========================
Coke -> Original -> 10$
-> Zero -> 8$
==========================
Pepsi -> Can -> 9$
-> Bottle. -> 10$
==========================
if I have 3 tables : products , variants , product_variant_tranx
any one can help me ?
Thanks
It's a little be late. But this type of question is common for newcomers. I put here my answer for the newcomers who are coming here to search exact type of problems solution.
Every product may generate a unique id like p1,p2,...
Under the products, you enter the variants like variant one, variant two,.. with a unique id(generate when entry, may be visible in the user interface or hidden for working backend) like p1v1,p1v2, with pricing like p1v1 10$,p1v2 8$ etc.
Let's see the tables
Table1. products_table
product_name
product_id
Coke
p1
Pepsi
p2
Table2. variants_table
product_id
variant_name
variant_id
variant_price
p1
Original
p1v1
10$
p1
Zero
p1v2
8$
p2
Can
p2v1
9$
p2
Bottle
p2v2
10$
Call to the user interface
Query1. SELECT product_name,product_id FROM products_table
Then call
Query2. SELECT variant_name,variant_id,variant_price FROM products_table WHERE product_id='getting product id from Query1'
I show the basic logic for newcomers. If having a large number of products and variants then inner looping can jam your server. For this, you may use the same database structures but can use advanced SQL queries.
Relative sources which may help:
https://dev.mysql.com/doc/ (For learning advanced SQL queries)
https://cashflowinventory.com/blog/cash-flow-inventory-tutorial-products-management/ (Get concepts from a likely application's product management interface)

Separate tables vs map lists - DynamoDB

I need your help. I am quite new to databases.
I'm trying to get set up a table in DynamoDB to store info about TV shows. It seems pretty simple and straightforward but I am not sure if what I am doing is correct.
So far I have this structure. I am trying to fit everything about the TV shows into one table. Seasons and episodes are contained within a list of maps within a list of maps.
Is this too much layering?
Would this present a problem in the future where some items are huge?
Should I separate some of these lists of maps to another table?
Shows table
Ideally, you should not put a potentially unbounded list in a single row in DynamoDB because you could end up running into the item size limit of 400kb. Also, if you were to read or write one episode of one show, you consume capacity as if you are reading or writing all the episodes in a show.
Take a look at the adjacency list pattern. It’s a good choice because it will allow you to easily find the seasons in a show and the episodes in a season. You can also take a look at this slide deck. Part of the way through, it talks about hierarchical data, which is exactly what you’re dealing with.
If you can provide more information about your query patterns, I can give you more guidance on how to model your data in the table.
Update (2018-11-26)
Based on your comments, it sounds like you should use composite keys to establish hierarchical 1-N relationships.
By using a composite sort key of DataType:ItemId where ItemId is a different format depending on the data type, you have a lot of flexibility.
This approach will allow you to easily get the seasons in the show, get all episodes in all seasons, get all episodes in a particular season, or even get all episodes between season 1, episode 5 and season 2 episode 5.
hash_key | sort_key | data
----------|-----------------|----------------------------
SHOW_1234 | SHOW:SHOW_1234 | {name:"Some TV Show", ...
SHOW_1234 | SEASON:SE_01 | {descr:"In this season, the main character...
SHOW_1234 | EPISODE:S01_E01 | {...
SHOW_1234 | EPISODE:S01_E02 | {...
Here are the various key condition expressions for the queries I mentioned:
hash_key = "SHOW_1234" and sort_key begins_with("SEASON:") – gets all seasons
hash_key = "SHOW_1234" and sort_key begins_with("EPISODE:") – gets all episodes in all season
hash_key = "SHOW_1234" and sort_key begins_with("EPISODE:S02_") – gets all episodes in season 2
hash_key = "SHOW_1234" and sort_key between "EPISODE:S01_E5" and "EPISODE:S02_E5" – gets all episodes between season 1, episode 5 and season 2 episode 5

How would you find the most specific "filter" that matches a document? (determining which market segment a user fits in)

Imagine you have actions setup for when a user is from a certain demographic/market segment. The filters work a bit like a graph, matching for country, region, platform, operating system, and browser.
By default, you will match any value (if you specify US, you match for all users from the US regardless of region, platform, OS, or browser)
If you specify multiple values for any property of the filter it works like an OR (can be any of the values you specified), for the filter to match all the properties must have at least one match or be empty (accept all), essentially an AND operation.
So we can have:
Segment #1:
Countries: United States, Canada
Segment #2:
Countries: United States
Regions: New York
Platform: Tablets
Segment #3
Countries: United States
Browser: Chrome
Segment #4
Countries: United States
Segment #5
Match all (all filters left empty)
Scenario #1
User from Canada on his Tablet
Result: Segment #1
Scenario #2
User from New York, United States visits from Google Chrome on his Tablet.
Result: Segment #2, because the filter more specifically matches the user (matches country, region, and platform)
Scenario #3
User from Texas visits from his desktop
Result: Segment #4, tie with segment #1 is resolved because Segment #4 only matches United States and is therefore more specific
Work so far
I was thinking I could take each segment and load it up into a graph database that looks something like this
Country -> Region -> Platform --> OS -> Browser -> Segment
Each node either has a value (ex: United States, Chrome, Firefox, etc) and relationships that link it to any node below it in the tree (Country -> Browser is okay, Browser -> Country is not) or is null ("match all").
Each relationship (represented by ->) would also store a weight used to resolve ties. Relationships from a catch-all node get the max weight as they will always lose to a more specific filter.
Example database (numbers on the lines are the weight, lower weight becomes the prefered path)
Potential query
So now I need a query (maybe neo4j can do this?) that does the following:
Find the top level country node with the same value as the user or null
Go through each relationship (sorted by weight in ascending order)
Find the longest path, ties go to the node connected by a relationship with the lowest weight (if the tie is between a relationship to a null/catch-all node, the null node loses)
Continue this loop until we find a segment #
I'm sorry for the long post, it's hard to explain what I'm getting at via text.
What I'm looking for
Am I on the right path to solving this problem?
Are there better ways to go about this?
What would be the best way to store these relationships (graph database?)
How can I build a query that does what I want?
tl;dr: Need a way decent/performant way of finding the longest/most specific path in a graph like data structure. Comments requesting clarification or with any related information/documentation/projects/reading are very welcome
With Neo4j, you can store properties in a relationship, example:
(u1:User{name:"foo"})-[:FRIEND_WITH{since : "2015/01/01"}]->(u2:User{name:"bar"})
I think you should store country nodes this way:
(usa:Country{name: "USA", other attributes...})
So you can find every single country by matching with Country label, and then filter with the name property to get the one you're looking for.
Same for the cities, you can do a simple relationship to store every city :
(usa:Country{ name: "USA"})-[:CONTAINS_CITY]->(n:City{name: "New York", other attributes...})
and then you can add platform etc after the city.
To match a segment related to a certain country, you can do this way (example for Scenario #1) :
Match (c:Country{name : "Canada"})-[*1..2]->(p:Platform{name : "Tablet"})-[*1..]->(s:Segment) return s
Then you can create your segment by using nodes and create relations between them, the only problem may be on this case:
User1 has a Tablet in Canada
User2 has a Tablet in Canada using
Chrome
In this case, because of the depth match on the relationship ([*1..]) the User1 can be on the same segment as User2. The solution is to create intermediate nodes with default values, in case you don't have browser informations for example.

Display taxonomy term content based on session

I am able to display the region based on IP using the below code:
if ($_SESSION['smart_ip']['location']['country_code'] == 'IN'): ?>
India content specific
Now I want to use a taxonomy term like India and display the content, whichever posted in India.
I want to print the nodes, which has term as India only if the above condition satisfies:
foreach ((array)$taxonomy as $item) print $item-> India
If you have a catalog that allows you to identify the geographical location some session is associated with you could add an attribute 'search terms' to each entry in that catalog. That way once you identify the location in the catalog the session is associated with you have a list of search terms. You can then use these seach terms to filter a database query for all posts to get only those posts that contain one or all of the given search terms.
The list of search terms for the example india might start with (India,Bhārat,Gaṇarājya,...)...

ASP.Net / MySQL : Translating content into several languages

I have an ASP.Net website which uses a MySQL database for the back end. The website is an English e-commerce system, and we are looking at the possibility of translating it into about five other languages (French, Spanish etc). We will be getting human translators to perform the translation - we've looked at automated services but these aren't good enough.
The static text on the site (e.g. headings, buttons etc) can easily be served up in multiple languages via .Net's built in localization features (resx files etc).
The thing that I'm not so sure about it how best to store and retrieve the multi-language content in the database. For example, there is a products table that includes these fields...
productId (int)
categoryId (int)
title (varchar)
summary (varchar)
description (text)
features (text)
The title, summary, description and features text would need to be available in all the different languages.
Here are the two options that I've come up with...
Create additional field for each language
For example we could have titleEn, titleFr, titleEs etc for all the languages, and repeat this for all text columns. We would then adapt our code to use the appropriate field depending on the language selected. This feels a bit hacky, and also would lead to some very large tables. Also, if we wanted to add additional languages in the future it would be time consuming to add even more columns.
Use a lookup table
We could create a new table with the following format...
textId | languageId | content
-------------------------------
10 | EN | Car
10 | FR | Voiture
10 | ES | Coche
11 | EN | Bike
11 | FR | Vélo
We'd then adapt our products table to reference the appropriate textId for the title, summary, description and features instead of having the text stored in the product table. This seems much more elegant, but I can't think of a simple way of getting this data out of the database and onto the page without using complex SQL statements. Of course adding new languages in the future would be very simple compared to the previous option.
I'd be very grateful for any suggestions about the best way to achieve this! Is there any "best practice" guidance out there? Has anyone done this before?
In your case, I would recommend using two tables:
Product
-------------------------------
ProductID | Price | Stock
-------------------------------
10 | 10 | 15
ProductLoc
-----------------------------------------------
ProductID | Lang | Name | Description
-----------------------------------------------
10 | EN | Bike | Excellent Bike
10 | ES | Bicicleta | Excelente bici
This way you can use:
SELECT * FROM
Product LEFT JOIN ProductLoc ON Product.ProductID = ProductLoc.ProductID
AND ProductLoc.Lang = #CurrentLang
(Left join just in case there is no record for the current lang in the ProductLoc table)
It's not good idea just to add new columns to existing table. It will be really hard to add a new language in the feature. The lookup table is much more better but I think you can have problem with performance because number of translated records.
I think best solution is to have a shared table:
products: id, categoryid,
and same tables for every language
products_en, products_de: product_id (fk), title, price, description, ...
You will just select from the shared one and join table with your language. The advantage is that you can localize even the price, category, ...

Resources