Workfront: Set predecessor when adding a task - workfront-api

I'm using the java and the Workfront API to create a new task and would like to specify a predecessor while creating the task. If I add the task first, then update it, I am able to add the predecessor but I'd prefer to specify the predecessor when adding the task if possible.
Here's what I've tried but I have no luck. I just get a 500 error (internal server error).
...
Map<String, Object> map = new HashMap<String, Object>();
map.put( "name", "Test Task" );
map.put( "projectID", projectId );
JSONArray array = new JSONArray();
JSONObject jsonObj = new JSONObject();
jsonObj.put( "predecessorID", predecessorId );
jsonObj.put( "predecessorType", "fs" );
array.put( jsonObj );
map.put( "predecessors", array );
client.post( "task", map );
Has anyone been able to do this? Am I just missing something?

I'm almost positive that you can't set dependencies in the same operation as object creation. You'll have to PUT an update on the object after its creation. I'm not sure about the syntax for your Java implementation, but this is what the raw HTTP call would look like:
PUT https://<url>.my.workfront.com/attask/api/v9.0/task/<uuid>?updates={predecessors:[{predecessorID:"<ID of dep>",predecessorType:"<ss/sf/fs/ff>"}]}&apiKey=<key>

Related

dynamic consumer group in kafka listeners combined with RecordFilterStrategy

I would like to create different consumer groups dynamically for my kafka listener, therefore I have given up the standard way with #KafkaListener and went throw the manual
way with a ContainerProperties which is working fine like the example below.
However I can't use setRecordFilterStrategy because it is only present in the kafka listener
version ConcurrentKafkaListenerContainerFactory.
Do you know a way to do it or another to have dynamic consumer group and the possibility to use record filter strategy at the same time ?
Regards,
Luc
Map<String, Object> consumerConfig = ImmutableMap.of(
BOOTSTRAP_SERVERS_CONFIG, "brokerAddress",
GROUP_ID_CONFIG, "groupId"
);
DefaultKafkaConsumerFactory<String, String> kafkaConsumerFactory =
new DefaultKafkaConsumerFactory<>(
consumerConfig,
new StringDeserializer(),
new StringDeserializer());
ContainerProperties containerProperties = new ContainerProperties("topicName");
containerProperties.setMessageListener((MessageListener<String, String>) record -> {
//do something with received record
}
ConcurrentMessageListenerContainer container =
new ConcurrentMessageListenerContainer<>(
kafkaConsumerFactory,
containerProperties);
container.start();
See FilteringMessageListenerAdapter. So, you provide your MessageListener and some RecordFilterStrategy.
More in docs: https://docs.spring.io/spring-kafka/docs/current/reference/html/#filtering-messages

following parametered script in java is not supported?why?

i send parametered script to remote gremlin-server, but some scripts are success, some scripts are wrong.
for example, the following testcase is success, and the gremlin server returns the expect result
List<Long> ids = Lists.newArrayList(19496288L, 40076200L, 8717992L, 36070256L, 39303024L, 53232552L);
Map<String, Object> parameters = new HashMap<>();
parameters.put("ids1", ids);
parameters.put("ret", new String[]{"linkid", "locnwid", "remnwid"});
String strIds = "19496288,40076200,8717992,36070256,39303024,53232552";
String script = String.format("g.V(ids1).outE('L2_LINK').where(otherV().hasId(%s)).valueMap(ret).by(unfold())", strIds)
// this query script is also ok
// String.format("g.V().hasId(ids1).outE('L2_LINK').where(otherV().hasId(%s)).valueMap(ret).by(unfold())", strIds)
client.submit(script, parameters).all().get()
but the following testcase is wrong, the gremlin server return nothing
List<Long> ids = Lists.newArrayList(19496288L, 40076200L, 8717992L, 36070256L, 39303024L, 53232552L);
Map<String, Object> parameters = new HashMap<>();
parameters.put("ids1", ids);
parameters.put("ret", new String[]{"linkid", "locnwid", "remnwid"});
String strIds = "19496288,40076200,8717992,36070256,39303024,53232552";
String script = String.format("g.V(%s).outE('L2_LINK').where(otherV().hasId(ids1)).valueMap(ret).by(unfold())", strIds)
client.submit(script, parameters).all().get()
there is any wrong of my second query script? how to fix it?
another question:
i want to query the edges connecting nodes in a group, and the number of nodes exceeds 255, how to construct the query script to getting the edges by searching once?
after many tries, following script can work, but i do not known why.
String script = String.format("g.V(ids1).outE('L2_LINK').where(otherV().id().is(within(ids1))).valueMap(ret).by(unfold())", strIds)

Alfresco error: Model '{custom.model}custommodel' does not exist

Using Alfresco 5.0 community edition.
When trying to deploy the custom model provided in the answer to another question,
but using the dynamic deployment approach as specified at [http://docs.alfresco.com/5.0/tasks/deploy-dynamic.html]
Although the GUI says the model is "activated", I get the following WARN in the alfresco.log:
21:24:30,587 WARN [org.alfresco.repo.dictionary.DictionaryDAO] [ajp-apr-8009-exec-4]
org.alfresco.service.cmr.dictionary.DictionaryException:
00140008 Model '{custom.model}custommodel' does not exist
When I try to use it with CMIS 1.1, I'm getting an error back from the web service:
Type 'P:cmod:customDoc' is unknown!
Here is the relevant bit of the code which uses opencmis java api:
Map<String, Object> props = new HashMap<String, Object>();
props.put("cmis:objectTypeId", "cmis:document");
props.put("cmis:secondaryObjectTypeIds", Arrays.asList(new String[] {"P:cm:titled", "P:cmod:customDoc"}));
props.put("cmis:name", "myName");
props.put("cmod:property1", "value1");
ObjectId id = folder.createDocument(props, contentStream, VersioningState.MAJOR);
Am I specifying the namespace and aspect correctly (P:cmod:customDoc)? I've also tried cmod:aspectBase and other combinations, getting the same error.
My goal is to make a simple model where I can add a few extra fields to document objects (extending the default ContentModel).
It seems the warning is just that, it can be ignored.
But using CMIS 1.1, I have to do two steps to add in the extra properties from the custom aspect. (Trying to do it in one step gives the error "Type 'P:cmod:customDoc' is unknown!")
First createDocument() with the cmis:secondaryObjectTypeIds including the custom namespace, BUT don't add any custom properties.
Second, add the custom properties to the resulting document, and then updateProperties(). This will add in the custom property values to the document.
Map<String, Object> props = new HashMap<String, Object>();
props.put("cmis:objectTypeId", "cmis:document");
props.put("cmis:secondaryObjectTypeIds",
Arrays.asList(new String[] {"P:cm:titled", "P:cmod:customDoc"}));
props.put("cmis:name", "myName");
Document document = folder.createDocument(props, contentStream, VersioningState.MAJOR);
props = new HashMap<String, Object>();
props.put("cmod:property1", "value1"); //here is where you add the custom properties
document = (Document) document.updateProperties(properties);
(note: you need to reassign the document from the updateProperties result, otherwise it will be missing some information, such as parents)

"Unexpected list type" exception when invoking ISessionAwareCoreService.GetList()

I am invoking the Tridion 2011 SP1 core service via the shipped client assembly. When I attempt to list the contents of a publication, I get an exception.
The code (simplified) looks like this:
ItemsFilterData filter = new Tridion.ContentManager.CoreService
.Client.RepositoryItemsFilterData.RepositoryItemsFilterData();
filter.ItemTypes = new ItemType[] {
ItemType.Folder,
ItemType.StructureGroup
};
filter.Recursive = false;
IEnumerable<IdentifiableObjectData> childItems = core.GetList("tcm:0-15-1", filter);
Note: the variable "core" refers to an ISessionAwareCoreService which I can successfully use to call, for example core.GetSystemWideList()
When .GetList is invoked, I get the following exception:
System.ServiceModel.FaultException`1 was unhandled
Message=Unexpected list type:
Tridion.ContentManager.Data.ContentManagement.RepositoryItemsFilterData.
What are the possible causes of this problem? Can you suggest a good general approach for interpreting this kind of message?
You can't get the direct children of a Publication using GetList. Instead you should just load the PublicationData with a client.Read and then access the RootFolder and RootStructureGroup on that.
PublicationData pub = (PublicationData)core.Read("tcm:0-1-1", new ReadOptions());
string rootFolder = pub.RootFolder.IdRef;
string rootSG = pub.RootStructureGroup.IdRef;
Alternatively you can call GetListXml with your RepositoryItemsFilterData and extract the items from the XML yourself.
XElement listResult = core.GetListXml(parent.ID, filter);

structureMap mocks stub help

I have an BLL that does validation on user input then inserts a parent(PorEO) and then inserts children(PorBoxEO). So there are two calls to the same InsertJCDC. One like this=>InsertJCDC(fakePor) and another like this=>InsertJCDC(fakeBox).
When I stub out the parent I want to return fakePor. But when I run the code it returns null instead. Here is the unit test.
[Test]
public void PorBLL_InsertByPorInsertCV_DoingGoodCase()
{
// Startup object mapper
_Bootstrapper.Bootstrap();
// create the mock for generic Crud
IGenericCrud mockGenericCrud = MockRepository.GenerateMock<IGenericCrud>();
PorInsertCV fakePor = new PorInsertCV();
PorBoxInsertCV fakeBox = new PorBoxInsertCV();
// build fake return
PorEO fakePorNewRow = new PorEO();
fakePorNewRow.PorId = 22;
// stub parent and child insert routines.
mockGenericCrud.Stub(c => c.InsertJCDC<PorEO, PorInsertCV>(fakePor)).Return(fakePorNewRow);
mockGenericCrud.Stub(c => c.InsertJCDC<PorBoxEO, PorBoxInsertCV>(fakeBox)).Return(null);
ObjectFactory.Inject(typeof(IGenericCrud), mockGenericCrud);
IPorBLL localWithMock = ObjectFactory.GetInstance<IPorBLL>();
// build user args to csll bll with and use for insert
PorInsertCV userArgs = new PorInsertCV();
userArgs.AccessionNbr = "364-80-0007";
userArgs.NbrBoxes = 11;
userArgs.RegId = 20;
userArgs.TransmitedDt = Convert.ToDateTime("1/30/1980");
// call the bll using the stub
localWithMock.InsertByPorInsertCV(userArgs);
}
Any help is greatly appreciated
I can't really follow your code that well, but I'll give it a shot.
From my skills of deduction, this line here is the one giving you issues:
mockGenericCrud.Stub(c => c.InsertJCDC<PorEO, PorInsertCV>(fakePor)).Return(fakePorNewRow);
Because you're expecting fakePorNewRow to be returned when you call localWithMock.InsertByPorInsertCV(userArgs); - yeah?
If that's your case, what your problem is, is that it will only return fakePorNewRow when it is given fakePor ... not userArgs as you have given it.
Tell me if I'm completely off track.
HTHs,
Charles
Ps. You might want to add the tag of which mocking framework you are using to the question.

Resources