Watson conversation - context - previous input text - watson-conversation

During a conversation sequence, when an user provides an input for a response coming from the conversation service based on his/her previous question, I am building a new request to the conversation service by passing the previous question as input text and the previous context.
The previous context is to let the Conversation service know the conversation id. The previous input text (question) is to let the Conversation service identify and resume from where it was left (the right dialog node).
My application uses the user input for validation and updating the context. For instance, setting the context as user "verified" etc.
My application gets the previous input text from the context object of conversation service.
Could you please let me know if i am doing right?

Related

How do I find out a field's type information for a 'record' in appmaker in Server script?

I'm trying to create a re-usable script for capturing record changes onSave with Server-side scripting. To do that, I need the model information for a given table, including what type each field is.
I have figured out how to get the model for my table and details for the fields:
var table = "Clients";
var myObject = app.models[table];
// Dump the properties of the 2nd field in the model
console.log("Field 2 properties: " + JSON.stringify(myObject["L"]["fields"]["1"]));
I see this:
{"name":"Client",
"key":"zzzkS1spSPKkRXMn",
"displayName":null,
"description":"Short name for client (must be unique)",
"type":{},
"required":false,
"uid":false,
"defaultValue":null,
"minLength":0,
"maxLength":null,
"integer":false,
"sortable":true,
"minValue":null,
"maxValue":null,
"regexp":null,
"regexpError":null,
"possibleValues":null,
"aggregationType":null
}
"type" looks like an empty property here and I can't seem to figure out how to get any reference to it to tell me what I need.
How do I get usable type information for a given field in a model?
Right now, App Maker doesn't expose an API to access the model metadata.
You snippet is actually accessing App Maker's internal state and might break in future releases (the "L" property is actually obfuscated by a JS compiler and not designed to be accessed from user land).
We know this kind of meta-programming is handy and this is something we might add in the future based on user feedback. Please feel free to submit a request feature in our issue tracker (https://developers.google.com/appmaker/support).

How to create a Rule on Drupal that creates activity streams of followed users?

I'm using Flags, Commons follow, Message and Rules modules to create the ability for users to follow each other.
I use commons auto generated commons_follow_user flag to create a follow button. I generate that button through views on each node. If user A presses the button on the node submitted by user B, user A starts following user B. By default commons follow user module shows user B name on user A account page. What I also need is for user A to see activity stream of the user B, more specifically to see when user B adds new node. I understand that I have to use rules and messages modules. I have created a rule that triggers Message entity creation on new node creation but how do I make this stream only visible to users following the user that creates those nodes? Is there a way with rule conditions? Or should I look in the other direction to achieve this?
It looks like you're trying to create some sort of social network.
A module I'm pretty fond of us the Statuses module
If you're just looking for something that will post activity, there's also the heartbeat module
I hope that helps.

How to get the WorkItem of an object in Workflow?

In Tridion 2011 SP1, Event System, I'm trying to get the WorkItem of an object that I know is in workflow, but I don't know in whose WorkList it might be.
Scenario Description:
Page must remain locked while a given component is in workflow
If component workflow state changes, page state should change too
What I thought of doing was an Event triggered on FinishActivityEventArgs, which would:
Check if current item is Component
Get the corresponding page (GetUsingItems of type page)
Check if the page is also in workflow
Get the page in question
Get the WorkItem for the page
Finish the current activity and pass on the corresponding activity details
I am about ready with most steps but having doubts on step 5. The only method I see so far to get the WorkItems is using session.WorkflowManager.GetUserWorkItems(userWorkItemsFilter) but this will probably fail if the page is not in the current user's work items, right?
Any tips/directions?
I believe you will need to use the session.WorkflowManager.GetListProcesses method to find all the processes, rather than just the ones for the current user. I imagine you may need to impersonateate as an Administrator in order to get all the items back though.

Spring WebFlow, Validations and Models

I am building a sample Spring WebFlow application and wanted to get some inputs on how the handle the below scenario.
I have 2 pages, the first page is a form where the user inputs data and the second page just displays the data the user entered in the previous page. The first page has a 'discard' and a 'continue' link and the second page just has the edit link which takes the user to the first screen so as to make edits on the data.
The scenario I am testing is..the user enters data, hits the continue link, the validators(Spring/WebFlow validators) are executed and the second page is displayed with the data (correct data). Now the user hits the edit link, changes a field on the first page, hits the continue link, the validators are executed and a error message(ex. user entered an invalid email address in the email field which is define as String in the model object) is shown on the same page (first page). Now the user hits the discard link and goes to the second page where the data is displayed. Now since the validations on the first page failed, the data displayed is not the correct one (shows the invalid email address).
Appreciate if some one can help me with displaying the old data (correct data) once the user hits the discard link since the data/model is not persisted anywhere.
If you're on a view-state with a model and you take a transition with bind="true" (the default), the model object is changed for that snapshot. That is, once you "continue", you've updated the object.
I don't know if you could track and return the user to a previous snapshot. If not, you'd need to retain a "backup" object and manually restore that one in the code attached to "discard".

Flex-Cairngorm/Hibernate - Is EAGER fetching strategy pointless?

I will try to be as concise as possible. I'm using Flex/Hibernate technologies for my app. I also use Cairngorm micro-architecture for Flex. Because i'm beginner, i have probably misunderstand something about Caringorm's ModelLocator purpose. I have following problem...
Suppose that we have next data model:
USER ----------------> TOPIC -------------> COMMENT
1 M 1 M
User can start many topics, topics can have many comments etc. It is pretty simple model, just for example. In hibernate, i use EAGER fetching strategy for unidirectional USER->TOPIC and TOPIC->COMMENT relations(here is no question about best practices etc, this is just example of problem).
My ModelLocator looks like this:
...
public class ModelLocator ....
{
//private instance, private constructor, getInstance() etc...
...
//app state
public var users:ArrayCollection;
public var selectedUser:UserVO;
public var selectedTopic:TopicVO;
}
Because i use eager fetching, i can 'walk' through all object graph on my Flex client without hitting the database. This is ok as long as i don't need to insert, update, or delete some of the domain instances. But when that comes, problems with synchronization arise.
For example, if i want to show details about some user from some UserListView, when user(actor) select that user in list, i will take selected index in UserList, get element from users ArrayCollection in ModelLocator at selected index and show details about selected user.
When i want to insert new User, ok, I will save that user in database and in IResponder result method i will add that user in ModelLocator.users ArrayCollection.
But, when i want to add new topic for some user, if i still want to use convenience of EAGER fetching, i need to reload user list again... And to add topic to selected user... And if user is in some other location(indirectly), i need to insert topic there also.
Update is even worst. In that case i need to write even some logic...
My question: is this good way of using ModelLocator in Cairngorm? It seems to me that, because of mentioned, EAGER fetching is somehow pointless. In case of using EAGER fetching, synchronization on Flex client can become big problem. Should I always hit database in order to manipulate with my domain model?
EDIT:
It seems that i didn't make myself clear enough. Excuse me for that.
Ok, i use Spring in technology stack also and DTO(DVO) pattern with flex/spring (de)serializer, but i just wanted to stay out of that because i'm trying to point out how do you stay synchronized with database state in your flex app. I don't even mention multi-user scenario and poling/pushing topic which is, maybe, my solution because i use standard request-response mechanism. I didn't provide some concrete code, because this seems conceptual problem for me, and i use standard Cairngorm terms in order to explain pseudo-names which i use for class names, var names etc.
I'll try to 'simplify' again: you have flex client for administration of above mentioned domain(CRUD for each of domain classes), you have ListOfUsersView(shows list of users with basic infos about them), UserDetailsView(shows user details and list of user topics with delete option for each of topic), InsertNewUserTopicView(form to insert new topic) etc.
Each of view which displays some infos is synchronized with ModelLocator state variables, for example:
ListOfUsersView ------binded to------> users:ArrayCollection in ModelLocator
UserDetailsView ------binded to------> selectedUser:UserVO in ModelLocator
etc.
View state transition look like this:
ListOfUsersView----detailsClick---->UserDetailsView---insertTopic--->InsertTopicView
So when i click on "Details" button in ListOfUsersView, in my logic, i get index of selected row in ListOfUsers, after that i take UserVO object from users:ArrayCollection in ModelLocator at mentioned index, after that i set that UserVO object as selectedUser:UserVO in ModelLocator and after that i change view state to UserDetailsView(it shows user details and selectedUser.topics) which is synchronized with selectedUser:UserVO in ModelLocator.
Now, i click "Insert new topic" button on UserDetailsView which results in InsertTopicView form. I enter some data, click "Save topic"(after successful save, UserDetailsView is shown again) and problem arise.
Because of my EAGER-ly fetched objects, i didn't hit the database in mentioned transitions and because of that there are two places for which i need to be concerned when insert new topic for selected user: one is instance of selectedUser object in users:ArrayCollection (because my logic select users from that collection and shows them in UserDetailsView), and second is selectedUser:UserVO(in order to sync UserDetailsView which comes after successfull save operation).
So, again my question arises... Should i hit database in every transition, should i reload users:ArrayCollection and selectedUser:UserVO after save in order to synchronize database state with flex client, should i take saved topic and on client side, without hitting the database, programmatically pass all places which i need to update or...?
It seems to me that EAGER-ly fetched object with their associations is not good idea. Am i wrong?
Or, to 'simplify' :) again, what should you do in the mentioned scenario? So, you need to handle click on "Save topic" button, and now what...?
Again, i really try to explain this as plastic as possible because i'm confused with this. So, please forgive me for my long post.
From my point of view the point isn't in fetching mode itself but in client/server interaction. From my previous experience with it I've finally found some disadvantages of using pure domain objects (especially with eager fetching) for client/server interaction:
You have to pass all the child collections maybe without necessity to use them on a client side. In your case it is very likely you'll display topics and comments not for all users you get from server. The most like situation you need to display user list then display topics for one of the selected users and then comments for one of the selected topics. But in current implementation you receive all the topics and comments even if they are not needed to display. It is very possible you'll receive all your DB in a single query.
Another problem is it can be very insecure to get all the user data (or some other data) with all fields (emails, addresses, passwords, credit card numbers etc).
I think there can be other reasons not to use pure domain objects especially with eager fetching.
I suggest you to introduce some Mapper (or Assembler) layer to convert your domain objects to Data Transfer Objects aka DTO. So every query to your service layer will receive data from your DAO or Active Record and then convert it to corresponding DTO using corresponding Mapper. So you can get user list without private data and query some additional user details with a separate query.
On a client side you can use these DTOs directly or convert them into client domain objects. You can do it in your Cairngorm responders.
This way you can avoid a lot of your client side problems which you described.
For a Mapper layer you can use Dozer library or create your own lightweight mappers.
Hope this helps!
EDIT
What about your details I'd prefer to get user list with necessary displayable fields like first name and last name (to display in list). Say a list of SimpleUserRepresentationDTO.
Then if user requests user details for editing you request UserDetailsDTO for that user and fill tour selectedUser fields in model with it. The same is for topics.
The only problem is displaying list of users after user details editing. You can:
Request the whole list again. The advantage is you can display changes performed by other users. But if the list is too long it can be very ineffective to query all the users each time even if they are SimpleUserRepresentationDTO with minimal data.
When you get success from server on user details saving you can find corresponding user in model's user list and replace changed details there.
Tell you the truth, there's no good way of using Cairngorm. It's a crap framework.
I'm not too sure exactly what you mean by eager fetching (or what exactly is your problem), but whatever it is, it's still a request/response kind of deal and this shouldn't be a problem per say unless you're not doing something right; in which case I can't see your code.
As for frameworks, I recommend you look at RobotLegs or Parsley.
Look at the "dpHibernate" project. It implements "lazy loading" on the Flex client.

Resources