Closed ensean closed 9 years ago
I have not tried to find out the parameters of a Task before. I don't see that specified in the .bes file, so I think you may have to search through the actionscript text to figure that out.
Could use this RegEx: parameter\s"(.)"\s_of\s_action
The workaround you provide seems to be workable.
But here goes another question, how to get the actionscripts of one task?
I have not find getter method for the Class Task ...
Task inherits two methods from FixletWithAction: getAction() and getDefaultAction(). Please use those to get the actions from your fixlet.
getTasks method in IEMAPI is as follows:
public List<BESAPI.Task> getTasks(String siteType,String site){
return getBESAPIContent(buildSiteTarget(apiRoot.path("/tasks/"),siteType,site).request().get(),BESAPI.Task.class);
}
But BESAPI.Task seems not to inherits from any class...
public static class Task {
@XmlElement(name = "Name")
@XmlJavaTypeAdapter(NormalizedStringAdapter.class)
@XmlSchemaType(name = "normalizedString")
protected String name;
@XmlElement(name = "ID")
@XmlSchemaType(name = "nonNegativeInteger")
protected BigInteger id;
@XmlAttribute(name = "Resource")
@XmlJavaTypeAdapter(NormalizedStringAdapter.class)
@XmlSchemaType(name = "normalizedString")
protected String resource;
@XmlAttribute(name = "LastModified")
@XmlJavaTypeAdapter(NormalizedStringAdapter.class)
@XmlSchemaType(name = "normalizedString")
protected String lastModified;
/**
* Gets the value of the name property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getName() {
return name;
}
/**
* Sets the value of the name property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setName(String value) {
this.name = value;
}
/**
* Gets the value of the id property.
*
* @return
* possible object is
* {@link BigInteger }
*
*/
public BigInteger getID() {
return id;
}
/**
* Sets the value of the id property.
*
* @param value
* allowed object is
* {@link BigInteger }
*
*/
public void setID(BigInteger value) {
this.id = value;
}
/**
* Gets the value of the resource property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getResource() {
return resource;
}
/**
* Sets the value of the resource property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setResource(String value) {
this.resource = value;
}
/**
* Gets the value of the lastModified property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getLastModified() {
return lastModified;
}
/**
* Sets the value of the lastModified property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setLastModified(String value) {
this.lastModified = value;
}
public BESAPI.Task withName(String value) {
setName(value);
return this;
}
public BESAPI.Task withID(BigInteger value) {
setID(value);
return this;
}
public BESAPI.Task withResource(String value) {
setResource(value);
return this;
}
public BESAPI.Task withLastModified(String value) {
setLastModified(value);
return this;
}
}
I tried to cast from BESAPI.Task to Task, but failed
List<Task> taskList = (Task)client.getTasks("custom", "CGBsite");
Any suggestion?
You need to do the following:
List<BESAPI.Task> taskList = client.getTasks("custom","CGBsite");
Optional<com.bigfix.schemas.bes.Task> task = client.getTask(taskList.get(0));
Action action = task.get().getDefaultAction();
Note that there is a difference betwee com.bigfix.schemas.bes.Task and BESAPI.Task.
It seems that the static class BES.Task does not exist....
apologies com.bigfix.schemas.bes.Task
ooops, type mismatch for com.bigfix.schemas.bes.Task task = client.getTask(taskList.get(0));
Type mismatch: cannot convert from Optional
Ok, fixed that as well. This library uses google guava Optional classes in cases where a query might not return a result.
Thanks a lot for your prompt response :)
From the definition of the Task class, it seems that we can only get task_name/task_id, is it possible to get the detailed info, such as parameters(may be included in actionscripts)