Modifiable Collection Rally WSAPI - rally

I have a simple question about Rally WSAPI doc. Just to confirm, the Modifiable Collection field in the documentation informs if this collection can be updated or not, is that correct?

Yes. Using json dynamic object we can do it as below:
DynamicJsonObject newProjectPermission = new DynamicJsonObject();
newProjectPermission["User"] = myUser;
newProjectPermission["Project"] = myProject;
newProjectPermission["Role"] = "Editor";

Related

How iterate all Property of a node and update the value of each property and save in repository in cq5

My cq5 Content Structure is....
Content
---mywebsite
------base
-----us
--- en
----pageOne
----pageTwo
----pageThree
----pageFour
----cq:content
----par
----pageFourNew
"pageFourNew" has around 500 Properties.
Now I need to get all the properties of "pageFourNew" and to update their value.
For example if I have:
property=prop1
value = prop1 value
I want to do value = value+"some string value append" and save it on the repository.
I want to do this in a programmatically way.
Please share if you have any solution or idea.
You can use PropertyIterator to iterate through all the properties, setProperty() method of node api to set the new value and jcr session to persist the value to get this done. Sample code:
PropertyIterator propertyIterator = pageFourNew.getProperties();
while (propertyIterator.hasNext()) {
Property property = propertyIterator.nextProperty();
pageFourNew.setProperty(property.getName(),
property.getValue().getString() + "");
jcrSession.save();}
You can easily do this as suggested above at JCR level. But as per CQ practices and this blog
It is better practice to operate at Sling level and NOT JCR level, just to avoid overhead of managing the resources. You can use below code which works:
Resource resource = pageFourNew; // assuming you are getting sling resource properly
ModifiableValueMap valueMap = resource.adaptTo(ModifiableValueMap.class);
for(String key : valueMap.keySet()) {
String value = valueMap.get(key, String.class);
value = value + "additional texts";
valueMap.put(key, value);
}
resource.getResourceResolver().commit();
This is cleaner approach.

How to create a Result Set

I need to create a result set in phalcon and use it as it was an array.
Im trying to find an example or more info on the documentation but it seems it's not possible.
On the API you can see the contructor params, this one is for a Resultset/Simple
public function __construct($columnMap, $model, $result, \Phalcon\Cache\BackendInterface $cache=null, $keepSnapshots=null){ }
an example:
$robot = new Robot();
$robots = new Resultset(null, $robot, $robot->getReadConnection()->query($sql, $params));
You must take in consideration that the Resultset is not a collection, it is a traversable pointer to the database conecction. There is a post where the team will consider to add more "collection" functionalities to the object: https://github.com/phalcon/cphalcon/issues/10580

Using dynamic types with expresso

I would like to use a dynamic value as a parameter.
E.g.
dynamic dyn = new ExpandoObject();
dyn.Foo = "bar";
var bar = new Interpreter().Eval("d.Foo", new Parameter("d", dyn));
Assert.AreEqual("bar", bar.ToString());
But I get an error saying "No property or field 'Foo' exists in type 'ExpandoObject'" ?
Is this supposed to be possible?
Regards, Niels
Unfortunately for now dynamics (ExpandoObject) are not supported. I will consider this feature for the next release.
A possible workaround is to use anonymous objects:
dynamic dyn = new ExpandoObject();
dyn.Foo = "bar";
var bar = new Interpreter().Eval("d.Foo", new Parameter("d", new { Foo = dyn.Foo }));
Consider that in this case the property is evaluated when you create the parameter.
You can also convert a dynamic into an anonymous type (see Cast ExpandoObject to anonymous type) but the result is not very different.
Disclaimer: I'm the creator of Dynamic Expresso library.
Expression Evaluator supports dynamics (ExpandoObject). It supports method calls, property and index accessors, get and set. If you do encounter an error with dynamics please let me know as dynamics is relatively newly supported.

Creating new smartform data using Ektron ContentTypes

Ektron 8.0.1 SP1
I am using SmartForms and Content Types to read (and hopefully write) data. I can read data but now I am attempting to write a new record similar to the following.
ContentTypeManager<member> contentTypeManager = new ContentTypeManager<member>();
ContentType<member> newmem = new ContentType<member>();
newmem.SmartForm.details.field1 = "Chuck"; // This line throws 'Object reference not set to an instance of an object.' error
newmem.SmartForm.details.field2 = "Norris";
contentTypeManager.Update(newmem);
I get the error "Object reference not set to an instance of an object." for that first assignment line. What am I missing?
I am having trouble finding good documentation on ContentTypes for 8.0.1 now that the Ektron website has been redesigned.
Thx.
Thanks for clarifying, to ADD content to a folder that has a smartform assigned to it, the basic code block should get you started: (Note: the Html attribute of the content is simply the xml matched to the schema you created)
Ektron.Cms.Framework.Content.ContentManager cmanager = new Cms.Framework.Content.ContentManager();
Ektron.Cms.ContentData cdata = new ContentData();
cdata.FolderId = 0;
cdata.XmlConfiguration.Id = 0; //SMARTFORM ID HERE
cdata.Html = "<root><field1>field1 value</field1><field2>field2 value</field2></root>";
cmanager.Add(cdata);
You could update ContentTypes.cs to include an Add method. Just copy the Update method and change contentManager.Update to contentManager.Add.
public void Add(ContentType<T> contentType)
{
Initialize();
contentType.Content.Html = Ektron.Cms.EkXml.Serialize(typeof(T), contentType.SmartForm);
contentManager.Add(contentType.Content);
}
Unfortunately, contentManager.Add returns void. Ideally it should return the new content ID.

How to create a Task belonging to an Iteration using Rally Api and .NET

I am new to the Rally API and just having some trouble creating a Task using the Rally.RestApi library. I need to create a Task (using .NET) and associate it with a User Story (in which the User Story belongs to a certain Iteration).
Do I have to get the User Story first, then add a Task to it? How would I do that?
Thanks.
All objects in Rally have a unique url called a ref.
You just need the story's ref to associate the two:
RallyRestApi restApi = new RallyRestApi("myuser#company.com", "password",
"https://rally1.rallydev.com", "1.27");
DynamicJsonObject newTask = new DynamicJsonObject();
newTask["Name"] = "My New Task";
newTask["WorkProduct"] = "/hierarchicalrequirement/12345"; //your story ref here
CreateResult createResult = restApi.Create("task", newTask);