Serach Node using Query Builder In AEM? - aem

i need to get some asset node use Query Builder How I search i am gving folder path
1 :/content/dam/assets/en_us/myDatas/c02442188
2: /content/dam/assets/en_us/myDatas/c02442189
3: /content/dam/assets/ar_sa/myDatas/c02442170
4: /content/dam/assets/spanish/myDatas/c02442171
5: /content/dam/assets/spanish/B/c02442172
from thse asset
i need to get only 1,2,3,4
which means 'myDatas' folder contains.
need to get this nodes using query builder
i started query builder like this
path=/content/dam/assets
type=sling:Folder

path=/content/dam/assets
type=sling:Folder
nodename=myDatas*

Related

How to update information in an existing node instead of creating a new one using Dgraph?

I am writing a Golang application using Dgraph for persisting objects. From the documentation, I can infer that a new UID and hence a new node is created everytime I mutate an object/run the code.
Is there a way to update the same node data instead for creating a new node?
I tried changing the UID to use "_:name" for the UID field but even this creates a new node everytime the application is run. I wish to be able to update the existing node if it is already present in the DB instead of creating a new node for it.
Unfortunately the docs aren't very beginner friendly yet :/
To modify / mutate existing data you have to run a set operation and supply a rdf-triple like <uid> <predicate> "value" / <objectYouWantToModify> <attributeYouWantToModify> "quotedStringValue". If it is not an attribute but an edge, the value has to be another <uid>.
The full mutation would be for example
{
set {
<0x2> <name> "modified-name" .
}
}
The . terminates the sequence and there is an optional fourth parameter you can use to also assign a label.
Check https://www.w3.org/TR/n-quads/ for further details.

load only components scripts that are in the current page

What I'm trying to achieve is that if i have 2 components nodes :
component1
clientlib
component1.js
component2
clientlib
component2.js
and i drag them into page1, then when page1 is generated, only component1.js and component2.js will be loaded when navigating to page1 .
One approach i saw is to use custom Tag Library as described here : http://www.icidigital.com/blog/best-approaches-clientlibs-aem-part-3/
I have two questions :
1) is there an existing feature in AEM to do this ?
2) if not, what is the easiest way to create such custom Tag Library ?
EDIT:
Assume that there is no ability to just include all component clientLibs, rather load only those that are added to the page.
There is no built in feature to do this. Although I've heard that the clientlib infrastructure is being looked at for a re-write so I'm optimistic that something like this will be added in the future.
We have, and I know other company have, created a "deferred script tag." Ours is a very simple tag that take a chunk of html like a clientlib include, add it to a unique list and then on an out call at the footer, spits it all out one after another.
Here's the core of a simple tag implementation that extends BodyTagSupport. Then in your footer grab the attribute and write it out.
public int doEndTag() throws JspException {
SlingHttpServletRequest request = (SlingHttpServletRequest)pageContext.getAttribute("slingRequest");
Set<String> delayed = (Set<String>)request.getAttribute(DELAYED_INCLUDE);
if(delayed == null){
delayed = new HashSet<String>();
}
if(StringUtils.isNotBlank(this.bodyContent.getString())){
delayed.add(this.bodyContent.getString().trim());
}
request.setAttribute(DELAYED_INCLUDE, delayed);
return EVAL_PAGE;
}
Theoretically the possible way of doing is to write script in your page component/abstract page component that does something like this -
Step1 : String path = currentPage.getPath()
Step2 : Query this path for components (one way is to have a master list do a contains clause on sling:resourceType)
Step 3: User resource resolver to resolve the resourceType in Step 3, this will give you resource under your apps.
Step 4: From the above resource get the sub-resource with primary type as cq:ClientLibraryFolder
Step 5: from the client libs resource in Step 4 get the categories and include the JS from them
you could actually write a model to adapt a component resource to a clientLibrary to actually clean the code.
Let me know if you need actual code, I can write that in my free time.

Replacing the duplicate function for the 'unique' plugin

I am trying to write my own $.jstree.defaults.unique.duplicate function and replace it.
I tried doing so in the following jsFiddle (line: 68):
$.jstree.defaults.unique.duplicate = function(name, counter){
return name + "_test";
};
Steps to test:
Select Devices
Create Node called Node1
Create Another node under Devices called Node1
It will use the jstree default method to replace it with the default node name vs what my function provides
http://jsfiddle.net/2mbq86at/
Am I doing something wrong? Thanks in advance.
In your code you specify text to use in course of creating a new node.
Take out the pre-defined text and things will start to work as desired for your function $.jstree.defaults.unique.duplicate !
self.createFileNode = function (data) {
//Below code only allows files to be created within folders.
//Structure it as per createFolder method to create files at root
var data = {
//'id': 'tempId',
//'text': 'iOS 8'
}
....
In that case of course a new node's text will be the default 'New node'.
The best is to set a unique node name right upfront on creating a new node, like "text" : "OS_" + (new Date).getTime().
Still for the case of renaming nodes and duplicates: using the unique plugin, on renaming and choosing a duplicate text the node's text will fall back to the original one. If that is not what is desired, things get more complicated as the rename_node.jstree event will not be fired in that case.

CRM 2015 online, Business Process Flow, plugin error

Guys.
I have a custom BPF in a custom entity. There is a plugin triggered by another entity to update this custom entity which has BPF. The problem I have now is if the custom entity(with BPF) BPF stage is not first stage, the plugin will fail with this error:
The traversed path should end with the new active stage.
If the custom entity(with BPF) BPF stage is in first stage, then the plugin runs well. The plugin simply updates some fields of the custom entity(with BPF).
Could you guys please give me any advice? I really don't understand that error and I try to google it, but there is little information I can find.
Thanks.
if you get travesed path error their is an field in entity called
travesedpath
so this field contain stages id from 1st to current active stage
eg if your entity has a process flow and it has 6 stages and current active stage
is 3rd stage.
so travesedpath
contain 3 Guid from 1st stage to 3rd stage
like c1a07479-aa88-4b50-9675-61d840083530,efff5adb-48f2-47c7-8d0b-5f3807702f9b,a2717242-a072-4cd0-ac57-3a4eaddbcca7with comma separated
this travesedpath field is text field
in plugin you will first get traversedpath from current entity
or preimage then add new guid with this travesed path.
eg. string traversedPath = currentEntity.Attribute["traversedpath"];
thentravesedPath += newStageid;`
then update your entity
The problem here is that the BPF needs a list of all of the guids created as it uses it for branching. What that means is that you need to do the following:
string straversed = entity["traversedpath"].ToString();
string stageid = entity.Attributes["stageid"].ToString();
entity.Attributes["traversedpath"] = straversed + "," + stageid;
try
{
service.Update(entity);
}
The current stage is the last guid in the traversed path, so you add the stageid to the traversed path.
This should work! Let me know if it does!

Get assembly metadata in NDepend

I am trying to create CQL query which will select assemblies created by my company.
In my opinion the easiest way is to check data generated in AssemblyInfo, but I cannot find how to access it in CQL.
What about the code query:
from a in Application.Assemblies
where a.Name.StartsWith("YourCompany.YourProduct")
select a
Or do you need something more sophisticated?
Ok, what about getting inspiration from this default rule:
// <Name>UI layer shouldn't use directly DB types</Name>
warnif count > 0
// UI layer is made of types in namespaces using a UI framework
let uiTypes = Application.Namespaces.UsingAny(Assemblies.WithNameIn("PresentationFramework", "System.Windows", "System.Windows.Forms", "System.Web")).ChildTypes()
// You can easily customize this line to define what are DB types.
let dbTypes = ThirdParty.Assemblies.WithNameIn("System.Data", "EntityFramework", "NHibernate").ChildTypes()
// Ideally even DataSet and associated, usage should be forbidden from UI layer:
// http://stackoverflow.com/questions/1708690/is-list-better-than-dataset-for-ui-layer-in-asp-net
.Except(ThirdParty.Types.WithNameIn("DataSet", "DataTable", "DataRow"))
from uiType in uiTypes.UsingAny(dbTypes)
let dbTypesUsed = dbTypes.Intersect(uiType.TypesUsed)
select new { uiType, dbTypesUsed }
Of course the sets uiTypes and dbTypes must be refined with assemblies from level N and assemblies from level N+1.