value is not assigning to Inherited variable in node from a graph - jaseci

node dialogue_state{
has imprint;
}
node faq_root:dialogue_state{
has name = 'faq answer';
}
graph dialogue_system {
has anchor dialogue_root;
// can file.load_json;
spawn {
bienc = file.load_json(global.bi_enc_path);
name = bienc['faq_root'];
std.out("name\n\n");
std.out(name);
dialogue_root = spawn node::dialogue_root;
faq_root = spawn node::faq_root(imprint = {"list_imprint": bienc['faq_root'], "name": "faq_root"});
dialogue_root +[intent_transition(intent="faq_root")]+>faq_root;
}
faq_root, imprint is not getting the dictionary.
I tried assigning it to a variable before setting to in the node.
It was working before i upgrade.
I had 2 nodes with the same name. I changed one. Delete the graph and rebuild but it's still not working.

Related

How does the next object work in Linked List? How is it able to make another class objects point to the next address?

class Node
{
public int data;
public Node next;
public Node(int idata) {
data = idata;
next = null;
}
}
Node newnode = new Node(val);
newnode.next = null;
Like if I'm creating a new object newnode of the class Node , how is it able to use .next to find the next address of the list?
In your example code next is just null. Actually, it was not necessary to explicitly do newnode.next = null;, as it already was initialised to null in the Node constructor.
It becomes more interesting when you assign another new node to the next property of the node you have created:
Node newnode = new Node(1);
newnode.next = new Node(2);
In Java objects are accessed with references. newnode is such a reference, and newnode.next is also such a reference. Both are references to Node instances (if not null).
We could extend the linked list further:
newnode.next.next = new Node(3);
newnode.next.next.next = new Node(4);
When you realise that next is a property that can hold a value like any variable, then there is really no magic to it.
You could for instance also first create Node instances that are disconnected, and only after their creation link them together:
Node a = new Node(1);
Node b = new Node(2);
Node c = new Node(3);
Node d = new Node(4);
a.next = b;
b.next = c;
c.next = d;

Icinga2 check_load threshold on master node

I'm having an issue locating where to change the thresholds for the check_load plugin on the Icinga2 master node.
The best way is to redefine that command by adding the following to your commands.conf file in your conf.d directory. Add the following replacing <load> with whatever you want to call the command:
object CheckCommand "<load>" {
import "plugin-check-command"
command = [ PluginDir + "/check_load" ]
timeout = 1m
arguments += {
"-c" = {
description = "Exit with CRITICAL status if load average exceed CLOADn; the load average format is the same used by 'uptime' and 'w'"
value = "$load_cload1$,$load_cload5$,$load_cload15$"
}
"-r" = {
description = "Divide the load averages by the number of CPUs (when possible)"
set_if = "$load_percpu$"
}
"-w" = {
description = "Exit with WARNING status if load average exceeds WLOADn"
value = "$load_wload1$,$load_wload5$,$load_wload15$"
}
}
vars.load_cload1 = 10
vars.load_cload15 = 4
vars.load_cload5 = 6
vars.load_percpu = false
vars.load_wload1 = 5
vars.load_wload15 = 3
vars.load_wload5 = 4
}
The values you'll want to change are vars.load_cload1-15 and vars.wload1-15 or set them to varibles that you can set in the service definition with $variablename$.
Then in services.conf use the new name of your check command.

How to create a directory on the basis of path in cq5?

I have a String which is the path of the page for example /content/xperia/public/events/eventeditor. I am gererating the XML of this page and saving it to DAM, but I want to save it in the similar tree structure under /content.
I tried the following code
String page = "/content/xperia/public/events/eventeditor";
page = page.replace("/content", "/content/dam");
if (adminSession.nodeExists(page+ "/"+ "jcr:content")) {
Node node = adminSession.getNode(page+ "/"+ "jcr:content");
node.setProperty("jcr:data", sb.toString());
} else {
Node feedNode = JcrUtil.createPath(page,"nt:file", adminSession);
Node dataNode = JcrUtil.createPath(feedNode.getPath() + "/"+ "jcr:content", "nt:resource", adminSession);
dataNode.setProperty("jcr:data",sb.toString());
}
But it gives the following error
No matching child node definition found for
{http://www.jcp.org/jcr/1.0}content
Because there is no such path in the repository. Is there a way through which I can create a directory on the fly. Because to save this file, I need to create the entire tree xperia/public/events under /content/dam and then save eventeditor.xml in that directory .
Please suggest.
There are a few issues with your code. The JcrUtil.createPath(String absolutePath, String nodeType, Session session) creates all the non-existent intermediate path with the given NodeType.
This means that all the nodes xperia, public and events are created with type nt:file instead of sling:OrderedFolder.
You can use the createPath(String absolutePath, boolean createUniqueLeaf, String intermediateNodeType, String nodeType, Session session, boolean autoSave) method instead, to specify the type of intermediary nodes that are to be created.
String page = "/content/xperia/public/events/eventeditor";
page = page.replace("/content", "/content/dam");
page += ".xml";
if (adminSession.nodeExists(page+ "/"+ "jcr:content")) {
Node node = adminSession.getNode(page+ "/"+ "jcr:content");
node.setProperty("jcr:data", sb.toString());
} else {
Node feedNode = JcrUtil.createPath(page, true, "sling:OrderedFolder", "nt:file", adminSession, false);
Node dataNode = feedNode.addNode("jcr:content", "nt:resource");
dataNode.setProperty("jcr:data",sb.toString());
}
adminSession.save();

Nodes added to a page are not being saved in CQ

I have a service that's attempting to import blog pages into CQ 5.5.0. I am able to successfully create the page, but when I add nodes representing the content the nodes are not being saved. No errors are reported by CQ and I can see the nodes in the service immediately after creation. But when I look at the page in CRXDE Light the nodes are not part of the page content. The section of code that adds the nodes is here:
Node blogNode = blogPage.adaptTo(Node.class);
logOutput( INFO, "blogPage name = "+ blogPage.getName() );
// Create the author date node
Node authorDateNode = blogNode.addNode("jcr:content/authorDate", "nt:unstructured");
authorDateNode.setProperty("author", blog.getCreator());
authorDateNode.setProperty("date", sdf.format(blog.getPublishDate().getTime()));
authorDateNode.setProperty("sling:resourceType", "history/components/blog/authordate");
// Create the content node
Node blogPostNode = blogNode.addNode("jcr:content/blogPostBodyParSys", "nt:unstructured");
blogPostNode.setProperty("sling:resourceType", "history/components/parsys");
Node blogContentNode = blogNode.addNode("jcr:content/blogPostBodyParSys/text", "nt:unstructured");
blogContentNode.setProperty("sling:resourceType", "history/components/text");
blogContentNode.setProperty("text", blog.getContent());
blogContentNode.setProperty("textIsRich", "true");
// TODO: Test code only
NodeIterator itr = blogNode.getNode("jcr:content").getNodes();
while(itr.hasNext()) {
Node child = itr.nextNode();
logOutput(INFO, "Child node: " + child.getName(), 1 );
PropertyIterator propItr = child.getProperties();
while( propItr.hasNext() ) {
Property prop = propItr.nextProperty();
logOutput(INFO, "Property " + prop.getName() + ", value " + prop.getValue().getString(),2);
}
}
The test code at the bottom displays the newly created nodes and it shows values as expected. The last thing that occurs is a call to 'session.save' before the service exits.
No errors are reported but I do not see the nodes when I look at the page. Does anyone have any idea about what might be wrong here?
As pointed by #Sharath Maddapa you need to save the session. See the changes done in your code.
Node blogNode = blogPage.adaptTo(Node.class);
logOutput( INFO, "blogPage name = "+ blogPage.getName() );
// Create the author date node
Node authorDateNode = blogNode.addNode("jcr:content/authorDate", "nt:unstructured");
authorDateNode.setProperty("author", blog.getCreator());
authorDateNode.setProperty("date", sdf.format(blog.getPublishDate().getTime()));
authorDateNode.setProperty("sling:resourceType", "history/components/blog/authordate");
// Create the content node
Node blogPostNode = blogNode.addNode("jcr:content/blogPostBodyParSys", "nt:unstructured");
blogPostNode.setProperty("sling:resourceType", "history/components/parsys");
Node blogContentNode = blogNode.addNode("jcr:content/blogPostBodyParSys/text", "nt:unstructured");
blogContentNode.setProperty("sling:resourceType", "history/components/text");
blogContentNode.setProperty("text", blog.getContent());
blogContentNode.setProperty("textIsRich", "true");
//YOU must save the session here.
try {
blogNode.getSession().save();
} catch(Exception e) {// TODO Ideally log specific exceptions
logOutput( ERROR, "Error saving jcr session ");
}
// TODO: Test code only
NodeIterator itr = blogNode.getNode("jcr:content").getNodes();
while(itr.hasNext()) {
Node child = itr.nextNode();
logOutput(INFO, "Child node: " + child.getName(), 1 );
PropertyIterator propItr = child.getProperties();
while( propItr.hasNext() ) {
Property prop = propItr.nextProperty();
logOutput(INFO, "Property " + prop.getName() + ", value " + prop.getValue().getString(),2);
}
}
I appreciate the input and I finally figured out what was causing my problem: I had created two ResourceResolver instances so the session I was saving was apparently a different session from where the nodes were being created. And that session was not being saved.

JSTree creating duplicate nodes when loading data with create_node

I'm having an issue when I'm trying to load my initial data for JSTree; I have 2 top level nodes attached to the root node but when I load them it looks like the last node added is being duplicated within JSTree. At first it looked as if it was my fault for not specifically declaring a new object each time but I've fixed that. I'm using .net MVC so the initial data is coming from the model that is passed to my view (that is the data passed into the data parameter of the method).
this.loadInitialData = function (data) {
var tree = self.getTree();
for (var i = 0; i < data.length; i++) {
var node = new Object();
node.id = data[i].Id;
node.parent = data[i].Parent;
node.text = data[i].Text;
node.state = {
opened: data[i].State.Opened,
disabled: data[i].State.Disabled,
selected: data[i].State.Selected
};
node.li_attr = { "node-type": data[i].NodeType };
node.children = [];
for (var j = 0; j < data[i].Children.length; j++) {
var childNode = new Object();
childNode.id = data[i].Children[j].Id;
childNode.parent = data[i].Children[j].Parent;
childNode.text = data[i].Children[j].Text;
childNode.li_attr = { "node-type": data[i].Children[j].NodeType };
childNode.children = data[i].Children[j].HasChildren;
node.children.push(childNode);
}
tree.create_node("#", node, "last");
}
}
My initial code was declaring node like the following:
var node = {
id: data[i].Id
}
I figured that was the cause of what I'm seeing but fixing it has not changed anything. Here is what is happening when I run the application; on the first pass of the method everything looks like it is working just fine.
But after the loop is run for the second (and last) time here is the final result.
It looks like the node objects are just a copy of each other, but when I run the code through the debugger I see the object being initialized each time. Does anyone have an idea what would cause this behavior in JSTree? Should I be using a different method to create my initial nodes besides create_node?
Thanks in advance.
I found the issue; I didn't realize but I was setting my id property to the same id for both node groups. After I fixed it everything started working as expected.