Plugin - create feature when request is created

17 views
Skip to first unread message

Ameet Hasmucrai

unread,
Mar 22, 2016, 9:34:54 AM3/22/16
to DevTargetProcess
Hi,

I have created a plugin that is supposed to create a feature as soon as a request is created.
I can see in logs that the handler is called properly in the plugin, but no feature is created. And no errors are logged in the plugin log file and TP log file.
In another tests, I was able to create succesfully user stories and task.

Here is the class:


    class CreateFeature : IHandleMessages<RequestUpdatedMessage>
    {

        private readonly ICommandBus _bus;
        private readonly IStorageRepository _storage;
        private IActivityLogger LOG = ObjectFactory.GetInstance<IActivityLogger>();

        public CreateFeature(ICommandBus bus, IStorageRepository storage)
        {
            _bus = bus;
            _storage = storage;
        }

        public void Handle(RequestUpdatedMessage message)
        {
            LOG.Info("CreateFeature - Inicio");
            var requestDto = message.Dto;
            CreateFeatureAndUserStory(requestDto);
            LOG.Info("CreateFeature - Fim");
        }

        private void CreateFeatureAndUserStory(RequestDTO requestDto)
        {
            _bus.Send(new CreateFeatureCommand(new FeatureDTO
            {
                Name = requestDto.Name,
                ParentID = requestDto.RequestID,
                OwnerID = requestDto.OwnerID,
                ProjectID = requestDto.ProjectID
            }));
        }


    }


(note: to simplify the tests, I am handling request update only; after solving the issue of feature creation, I will update to handle request create)

Ameet Hasmucrai

unread,
Mar 22, 2016, 10:23:36 AM3/22/16
to DevTargetProcess
Hi,

I was looking again, and discovered that the feature was created, but was not visible because there was no relation with the request.
I cannot find the command to create a relation. I was able to find the DTO (GeneralRelationDTO).
Can anyone help?

Thanks

truh...@targetprocess.com

unread,
Oct 17, 2016, 12:27:24 PM10/17/16
to DevTargetProcess
Hello. The easiest option is to use REST api to create a feature with relation to this request.
Here is the json sample that you may post to http://yourTpAccount/api/v1/features:
{
Name:"1234333",
Project:{Id:1},
MasterRelations:[
{Master:{Id:6}, RelationType:{Id:1}}
]
}

Another options is to use sagas(http://dev.targetprocess.com/plugins/overview#saga), but it will be a bit harder, so I recommend REST.
Reply all
Reply to author
Forward
0 new messages