Search in sources :

Example 6 with Space

use of org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.Space in project linuxtools by eclipse.

the class OSIORestClient method postTaskData.

public RepositoryResponse postTaskData(TaskData taskData, Set<TaskAttribute> oldAttributes, TaskRepository repository, IOperationMonitor monitor) throws OSIORestException {
    Space space = null;
    if (taskData.isNew()) {
        TaskAttribute spaceAttribute = taskData.getRoot().getAttribute(OSIORestTaskSchema.getDefault().SPACE.getKey());
        Map<String, Space> spaces = getCachedSpaces(new NullOperationMonitor());
        space = spaces.get(spaceAttribute.getValue());
        String id = null;
        try {
            id = restRequestProvider.postNewTask(monitor, client, taskData, space, connector, repository);
        } catch (CoreException e1) {
            throw new OSIORestException(e1);
        }
        return new RepositoryResponse(ResponseKind.TASK_CREATED, id);
    } else {
        TaskAttribute spaceIdAttribute = taskData.getRoot().getAttribute(OSIORestTaskSchema.getDefault().SPACE_ID.getKey());
        String spaceId = spaceIdAttribute.getValue();
        try {
            space = getSpaceById(spaceId, repository);
        } catch (CoreException e1) {
            throw new OSIORestException(e1);
        }
        TaskAttribute newComment = taskData.getRoot().getAttribute(OSIORestTaskSchema.getDefault().NEW_COMMENT.getKey());
        if (newComment != null) {
            String value = newComment.getValue();
            if (value != null && !value.isEmpty()) {
                restRequestProvider.postNewCommentTask(monitor, client, taskData, oldAttributes);
                newComment.setValue("");
            }
        }
        TaskAttribute removeLinks = taskData.getRoot().getAttribute(OSIORestTaskSchema.getDefault().REMOVE_LINKS.getKey());
        if (removeLinks != null) {
            List<String> links = removeLinks.getValues();
            TaskAttributeMetaData metadata = removeLinks.getMetaData();
            TaskAttribute widAttr = taskData.getRoot().getAttribute(OSIORestTaskSchema.getDefault().UUID.getKey());
            String wid = widAttr.getValue();
            for (String link : links) {
                try {
                    String id = metadata.getValue(link);
                    restRequestProvider.deleteLink(monitor, client, wid, id);
                } catch (Exception e) {
                    StatusHandler.log(new Status(IStatus.ERROR, OSIORestCore.ID_PLUGIN, // $NON-NLS-1$
                    NLS.bind(// $NON-NLS-1$
                    "Unexpected error during deletion of work item link: <{0}>", link), e));
                }
            }
        }
        TaskAttribute addLink = taskData.getRoot().getAttribute(OSIORestTaskSchema.getDefault().ADD_LINK.getKey());
        TaskAttributeMetaData metadata = addLink.getMetaData();
        // $NON-NLS-1$
        String linkid = metadata.getValue("linkid");
        String sourceid = taskData.getRoot().getAttribute(OSIORestTaskSchema.getDefault().UUID.getKey()).getValue();
        // $NON-NLS-1$
        String targetid = metadata.getValue("targetWid");
        // $NON-NLS-1$
        String direction = metadata.getValue("direction");
        boolean isForward = true;
        if (direction != null && !direction.isEmpty()) {
            // $NON-NLS-1$
            isForward = direction.equals("forward");
        }
        if (linkid != null && targetid != null) {
            restRequestProvider.postNewLink(monitor, client, linkid, sourceid, targetid, isForward);
        }
        restRequestProvider.patchUpdateTask(monitor, client, taskData, oldAttributes, space);
        return new RepositoryResponse(ResponseKind.TASK_UPDATED, taskData.getTaskId());
    }
}
Also used : Space(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.Space) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) TaskAttribute(org.eclipse.mylyn.tasks.core.data.TaskAttribute) CoreException(org.eclipse.core.runtime.CoreException) RepositoryResponse(org.eclipse.mylyn.tasks.core.RepositoryResponse) TaskAttributeMetaData(org.eclipse.mylyn.tasks.core.data.TaskAttributeMetaData) CoreException(org.eclipse.core.runtime.CoreException)

Example 7 with Space

use of org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.Space in project linuxtools by eclipse.

the class TestOSIORestClient method testGetConfiguration.

@Test
public void testGetConfiguration() throws Exception {
    TestData testData = new TestData();
    TestUtils.initSpaces(requestProvider, testData);
    requestProvider.addGetRequest("/namedspaces/user", testData.spaces);
    OSIORestClient client = connector.getClient(repository, requestProvider);
    RepositoryLocation location = client.getClient().getLocation();
    location.setProperty(IOSIORestConstants.REPOSITORY_AUTH_ID, "user");
    location.setProperty(IOSIORestConstants.REPOSITORY_AUTH_TOKEN, "xxxxxxTokenxxxxxx");
    OSIORestConfiguration configuration = client.getConfiguration(repository, new NullOperationMonitor());
    Map<String, Space> spaces = configuration.getSpaces();
    assertEquals(spaces.size(), 2);
    assertTrue(spaces.containsKey("mywork"));
    assertTrue(spaces.containsKey("mywork2"));
}
Also used : Space(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.Space) TestData(org.eclipse.linuxtools.mylyn.osio.rest.test.support.TestData) OSIORestClient(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestClient) OSIORestConfiguration(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestConfiguration) RepositoryLocation(org.eclipse.mylyn.commons.repositories.core.RepositoryLocation) NullOperationMonitor(org.eclipse.mylyn.internal.commons.core.operations.NullOperationMonitor) Test(org.junit.Test)

Example 8 with Space

use of org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.Space in project linuxtools by eclipse.

the class TestOSIORestClient method testFormSearchURL.

@Test
public void testFormSearchURL() throws Exception {
    TestData testData = new TestData();
    TestUtils.initSpaces(requestProvider, testData);
    requestProvider.addGetRequest("/namedspaces/user", testData.spaces);
    OSIORestClient client = connector.getClient(repository, requestProvider);
    AbstractTaskDataHandler taskDataHandler = connector.getTaskDataHandler();
    TaskAttributeMapper mapper = taskDataHandler.getAttributeMapper(repository);
    TaskData taskData1 = new TaskData(mapper, repository.getConnectorKind(), repository.getRepositoryUrl(), "");
    assertTrue(taskDataHandler.initializeTaskData(repository, taskData1, null, null));
    taskData1.getRoot().createAttribute(OSIORestTaskSchema.getDefault().SPACE_ID.getKey()).addValue("SPACE-0001");
    taskData1.getRoot().createAttribute(OSIORestTaskSchema.getDefault().WORKITEM_TYPE.getKey()).addValue("bug");
    TaskData taskData2 = new TaskData(mapper, repository.getConnectorKind(), repository.getRepositoryUrl(), "");
    assertTrue(taskDataHandler.initializeTaskData(repository, taskData2, null, null));
    taskData2.getRoot().createAttribute(OSIORestTaskSchema.getDefault().SPACE_ID.getKey()).addValue("SPACE-0002");
    taskData2.getRoot().createAttribute(OSIORestTaskSchema.getDefault().WORKITEM_TYPE.getKey()).addValue("bug");
    List<TaskData> taskList = new ArrayList<>();
    taskList.add(taskData1);
    taskList.add(taskData2);
    String query = "filter[expression]={\"$AND\":[{\"$OR\":[{\"space\":\"SPACE-0001\"},{\"space\":\"SPACE-0002\"}]},{\"$OR\":[{\"workitemtype\":\"WORKITEMTYPE-0001\"}]}]}";
    String transformedQuery = URLQueryEncoder.transform(query);
    requestProvider.addGetRequest("/search?" + transformedQuery, taskList);
    RepositoryLocation location = client.getClient().getLocation();
    location.setProperty(IOSIORestConstants.REPOSITORY_AUTH_ID, "user");
    location.setProperty(IOSIORestConstants.REPOSITORY_AUTH_TOKEN, "xxxxxxTokenxxxxxx");
    location.setUrl("https://api.openshift.io/api");
    OSIORestConfiguration configuration = client.getConfiguration(repository, new NullOperationMonitor());
    Map<String, Space> spaces = configuration.getSpaces();
    TestTaskDataCollector collector = new TestTaskDataCollector();
    RepositoryQuery repoQuery = new RepositoryQuery("https://api.openshift.io/api/query?space=mywork&space=mywork2&baseType=bug");
    IStatus status = client.performQuery(repository, repoQuery, collector, new NullOperationMonitor());
    assertTrue(status.isOK());
    List<TaskData> dataList = collector.getTaskData();
    assertTrue(dataList != null);
    assertEquals(dataList.size(), 2);
    assertEquals(dataList.get(0), taskData1);
    assertEquals(dataList.get(1), taskData2);
}
Also used : Space(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.Space) IStatus(org.eclipse.core.runtime.IStatus) TestData(org.eclipse.linuxtools.mylyn.osio.rest.test.support.TestData) OSIORestConfiguration(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestConfiguration) ArrayList(java.util.ArrayList) AbstractTaskDataHandler(org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler) RepositoryLocation(org.eclipse.mylyn.commons.repositories.core.RepositoryLocation) TaskData(org.eclipse.mylyn.tasks.core.data.TaskData) IRepositoryQuery(org.eclipse.mylyn.tasks.core.IRepositoryQuery) OSIORestClient(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestClient) TaskAttributeMapper(org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper) NullOperationMonitor(org.eclipse.mylyn.internal.commons.core.operations.NullOperationMonitor) Test(org.junit.Test)

Example 9 with Space

use of org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.Space in project linuxtools by eclipse.

the class TestUtils method initSpaces.

@SuppressWarnings("deprecation")
public static void initSpaces(OSIOTestRestRequestProvider requestProvider, TestData test) {
    GenericLinksForSpace myworkLinks = new GenericLinksForSpace("/api/spaces/SPACE-0001", "", "/api/spaces/SPACE-0001/workitemtypes", "/api/spaces/SPACE-0001/workitemlinktypes", "/api/spaces/SPACE-0001/collaborators", "", "", null);
    WorkItemTypeFieldType stateFieldType = new WorkItemTypeFieldType("enum", "string", "", new String[] { "new", "open", "in progress", "resolved", "closed" });
    WorkItemTypeField field1 = new WorkItemTypeField("System status", "Status", Boolean.TRUE, stateFieldType);
    Map<String, WorkItemTypeField> fieldMap = new HashMap<>();
    fieldMap.put("system.state", field1);
    WorkItemLinkTypeAttributes linkAttributes = new WorkItemLinkTypeAttributes("Bug Blocker", "a bug blocker", 1, "2017/01/01", "2017/01/01", "blocks", "is blocked by", null);
    WorkItemLinkTypeData linkType = new WorkItemLinkTypeData("LINKTYPE-0001", "workitemlinktypes", linkAttributes, null, null);
    test.defaultWorkItemLinkTypeResponse = (new WorkItemLinkTypeResponse(new WorkItemLinkTypeData[] { linkType }));
    WorkItemTypeAttributes bugTypeAttributes = new WorkItemTypeAttributes("bug", "A bug", 1, "bug", "2017/01/01", "2017/01/01", fieldMap);
    WorkItemTypeData bugData = new WorkItemTypeData("WORKITEMTYPE-0001", "workitemtypes", bugTypeAttributes, null);
    WorkItemTypeAttributes featureTypeAttributes = new WorkItemTypeAttributes("feature", "A feature", 1, "feature", "2017/01/01", "2017/01/01", fieldMap);
    WorkItemTypeData featureData = new WorkItemTypeData("WORKITEMTYPE-0002", "workitemtypes", featureTypeAttributes, null);
    WorkItemTypeData[] defaultWorkItemData = { bugData, featureData };
    test.defaultWorkItemTypeResponse = (new WorkItemTypeResponse(defaultWorkItemData));
    UserAttributes user1Attributes = new UserAttributes("user", "user", new Date(2017, 01, 01), new Date(2017, 01, 01), "User", "//imageurl", "user", Boolean.TRUE, "user@user.org", "userCo", "", "//users/user", "");
    User user1 = new User("USER-0001", "users", user1Attributes, null);
    UserAttributes user2Attributes = new UserAttributes("user2", "user2", new Date(2017, 01, 01), new Date(2017, 01, 01), "User2", "//imageurl", "user2", Boolean.TRUE, "user2@user.org", "userCo", "", "//users/user2", "");
    User user2 = new User("USER-0002", "users", user2Attributes, null);
    UsersResponse userResponse1 = new UsersResponse(new User[] { user1, user2 });
    AreaAttributes area1Attributes = new AreaAttributes("mywork", 1, "2017/01/01", "2017/01/01", "", "");
    Area area1 = new Area("AREA-0001", "areas", area1Attributes, null, null);
    AreaAttributes area2Attributes = new AreaAttributes("otherarea", 1, "2017/01/01", "2017/01/01", "", "");
    Area area2 = new Area("AREA-0002", "areas", area2Attributes, null, null);
    AreaListResponse areaResponse1 = new AreaListResponse(new Area[] { area1, area2 }, null, null);
    IterationAttributes iteration1Attributes = new IterationAttributes("mywork", "mywork iteration", "2017/01/01", "2017/01/01", "", "", "", true, true, "", "");
    Iteration iteration1 = new Iteration("ITERATION-0001", "iterations", iteration1Attributes, null, null);
    IterationListResponse iterationResponse1 = new IterationListResponse(new Iteration[] { iteration1 }, null, null);
    SpaceAttributes myworkAttributes = new SpaceAttributes("mywork", "My work space", 1, "", "");
    SpaceOwnedBy ownedBy = new SpaceOwnedBy(new IdentityRelationData("USER-0001", "users"), new GenericLinks("https://api.openshift.io/api/users/user", "https://api.openshift.io/api/users/user", null));
    SpaceRelationships relationships = new SpaceRelationships(ownedBy, null, null, null, null, null, null, null, null);
    Space mywork = new Space("SPACE-0001", "spaces", myworkAttributes, relationships, myworkLinks);
    SpaceSingleResponse myworkResponse = new SpaceSingleResponse(mywork);
    LabelAttributes label1Attributes = new LabelAttributes("label1", "2017/01/01", "2017/01/01", "1", "", "", "");
    Label label1 = new Label("labels", "LABEL-0001", label1Attributes, null, null);
    LabelAttributes label2Attributes = new LabelAttributes("label2", "2017/01/01", "2017/01/01", "1", "", "", "");
    Label label2 = new Label("labels", "LABEL-0002", label2Attributes, null, null);
    LabelListResponse labelResponse1 = new LabelListResponse(new Label[] { label1, label2 }, null, null);
    requestProvider.addGetRequest("/spaces/SPACE-0001/workitemlinktypes", test.defaultWorkItemLinkTypeResponse);
    requestProvider.addGetRequest("/spaces/SPACE-0001/workitemtypes", test.defaultWorkItemTypeResponse);
    requestProvider.addGetRequest("/spaces/SPACE-0001/collaborators", userResponse1);
    requestProvider.addGetRequest("/spaces/SPACE-0001", myworkResponse);
    requestProvider.addGetRequest("/namedspaces/user/mywork", mywork);
    requestProvider.addGetRequest("/spaces/SPACE-0001/areas", areaResponse1);
    requestProvider.addGetRequest("/spaces/SPACE-0001/iterations", iterationResponse1);
    requestProvider.addGetRequest("/spaces/SPACE-0001/labels", labelResponse1);
    requestProvider.addGetRequest("/users/user", new UserSingleResponse(user1));
    GenericLinksForSpace mywork2Links = new GenericLinksForSpace("/api/spaces/SPACE-0002", "", "/api/spaces/SPACE-0002/workitemtypes", "/api/spaces/SPACE-0002/workitemlinktypes", "/api/spaces/SPACE-0002/collaborators", "", "", null);
    UsersResponse userResponse2 = new UsersResponse(new User[] { user1 });
    AreaAttributes area3Attributes = new AreaAttributes("mywork2", 1, "2017/01/01", "2017/01/01", "", "");
    Area area3 = new Area("AREA-0003", "areas", area3Attributes, null, null);
    AreaListResponse areaResponse2 = new AreaListResponse(new Area[] { area3 }, null, null);
    IterationAttributes iteration2Attributes = new IterationAttributes("mywork2", "mywork2 iteration", "2017/01/01", "2017/01/01", "", "", "", true, true, "", "");
    Iteration iteration2 = new Iteration("ITERATION-0002", "iterations", iteration2Attributes, null, null);
    IterationAttributes iteration3Attributes = new IterationAttributes("otheriteration", "mywork2 other iteration", "2017/01/01", "2017/01/01", "", "", "", true, true, "", "");
    Iteration iteration3 = new Iteration("ITERATION-0003", "iterations", iteration3Attributes, null, null);
    IterationListResponse iterationResponse2 = new IterationListResponse(new Iteration[] { iteration2, iteration3 }, null, null);
    SpaceAttributes mywork2Attributes = new SpaceAttributes("mywork2", "My work space2", 1, "", "");
    SpaceRelationships relationships2 = new SpaceRelationships(ownedBy, null, null, null, null, null, null, null, null);
    Space mywork2 = new Space("SPACE-0002", "spaces", mywork2Attributes, relationships2, mywork2Links);
    SpaceSingleResponse mywork2Response = new SpaceSingleResponse(mywork2);
    LabelAttributes label3Attributes = new LabelAttributes("label3", "2017/01/01", "2017/01/01", "1", "", "", "");
    Label label3 = new Label("labels", "LABEL-0003", label3Attributes, null, null);
    LabelAttributes label4Attributes = new LabelAttributes("label4", "2017/01/01", "2017/01/01", "1", "", "", "");
    Label label4 = new Label("labels", "LABEL-0004", label4Attributes, null, null);
    LabelListResponse labelResponse2 = new LabelListResponse(new Label[] { label3, label4 }, null, null);
    requestProvider.addGetRequest("/spaces/SPACE-0002/workitemlinktypes", test.defaultWorkItemLinkTypeResponse);
    requestProvider.addGetRequest("/spaces/SPACE-0002/workitemtypes", test.defaultWorkItemTypeResponse);
    requestProvider.addGetRequest("/spaces/SPACE-0002/collaborators", userResponse2);
    requestProvider.addGetRequest("/spaces/SPACE-0002", mywork2Response);
    requestProvider.addGetRequest("/namedspaces/user/mywork2", mywork2);
    requestProvider.addGetRequest("/spaces/SPACE-0002/areas", areaResponse2);
    requestProvider.addGetRequest("/spaces/SPACE-0002/iterations", iterationResponse2);
    requestProvider.addGetRequest("/spaces/SPACE-0002/labels", labelResponse2);
    requestProvider.addGetRequest("/users/user2", new UserSingleResponse(user2));
    GenericLinksForSpace mywork3Links = new GenericLinksForSpace("/api/spaces/SPACE-0003", "", "/api/spaces/SPACE-0003/workitemtypes", "/api/spaces/SPACE-0003/workitemlinktypes", "/api/spaces/SPACE-0003/collaborators", "", "", null);
    UsersResponse userResponse3 = new UsersResponse(new User[] { user2 });
    AreaAttributes area4Attributes = new AreaAttributes("mywork", 1, "2017/01/01", "2017/01/01", "", "");
    Area area4 = new Area("AREA-0004", "areas", area4Attributes, null, null);
    AreaListResponse areaResponse3 = new AreaListResponse(new Area[] { area4 }, null, null);
    IterationAttributes iteration4Attributes = new IterationAttributes("mywork", "mywork b iteration", "2017/01/01", "2017/01/01", "", "", "", true, true, "", "");
    Iteration iteration4 = new Iteration("ITERATION-0004", "iterations", iteration4Attributes, null, null);
    IterationListResponse iterationResponse3 = new IterationListResponse(new Iteration[] { iteration4 }, null, null);
    SpaceAttributes mywork3Attributes = new SpaceAttributes("mywork", "My work space3", 1, "", "");
    SpaceOwnedBy ownedBy3 = new SpaceOwnedBy(new IdentityRelationData("USER-0002", "users"), new GenericLinks("https://api.openshift.io/api/users/user2", "https://api.openshift.io/api/users/user2", null));
    SpaceRelationships relationships3 = new SpaceRelationships(ownedBy3, null, null, null, null, null, null, null, null);
    Space mywork3 = new Space("SPACE-0003", "spaces", mywork3Attributes, relationships3, mywork3Links);
    SpaceSingleResponse mywork3Response = new SpaceSingleResponse(mywork3);
    LabelAttributes label5Attributes = new LabelAttributes("label5", "2017/01/01", "2017/01/01", "1", "", "", "");
    Label label5 = new Label("labels", "LABEL-0005", label5Attributes, null, null);
    LabelListResponse labelResponse3 = new LabelListResponse(new Label[] { label5 }, null, null);
    requestProvider.addGetRequest("/spaces/SPACE-0003/workitemlinktypes", test.defaultWorkItemLinkTypeResponse);
    requestProvider.addGetRequest("/spaces/SPACE-0003/workitemtypes", test.defaultWorkItemTypeResponse);
    requestProvider.addGetRequest("/spaces/SPACE-0003/collaborators", userResponse3);
    requestProvider.addGetRequest("/spaces/SPACE-0003", mywork3Response);
    requestProvider.addGetRequest("/namedspaces/user2/mywork", mywork3);
    requestProvider.addGetRequest("/spaces/SPACE-0003/areas", areaResponse3);
    requestProvider.addGetRequest("/spaces/SPACE-0003/iterations", iterationResponse3);
    requestProvider.addGetRequest("/spaces/SPACE-0003/labels", labelResponse3);
    Map<String, Space> spaceMap = new TreeMap<>();
    spaceMap.put("mywork", mywork);
    spaceMap.put("mywork2", mywork2);
    test.spaceMap = spaceMap;
    SpaceResponse spaces = new SpaceResponse(new Space[] { mywork, mywork2 }, null, new SpaceListMeta(2));
    test.spaces = spaces;
    SpaceResponse externalspaces = new SpaceResponse(new Space[] { mywork3 }, null, new SpaceListMeta(1));
    test.externalspaces = externalspaces;
    requestProvider.addGetRequest("/namedspaces/user", spaces);
}
Also used : AreaAttributes(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.AreaAttributes) User(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.User) SpaceListMeta(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.SpaceListMeta) HashMap(java.util.HashMap) UsersResponse(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.UsersResponse) Label(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.Label) WorkItemLinkTypeResponse(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.WorkItemLinkTypeResponse) Iteration(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.Iteration) WorkItemTypeAttributes(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.WorkItemTypeAttributes) AreaListResponse(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.AreaListResponse) UserAttributes(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.UserAttributes) GenericLinks(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.GenericLinks) SpaceResponse(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.SpaceResponse) WorkItemTypeFieldType(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.WorkItemTypeFieldType) IdentityRelationData(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.IdentityRelationData) WorkItemLinkTypeAttributes(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.WorkItemLinkTypeAttributes) SpaceSingleResponse(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.SpaceSingleResponse) Space(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.Space) GenericLinksForSpace(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.GenericLinksForSpace) IterationAttributes(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.IterationAttributes) WorkItemTypeField(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.WorkItemTypeField) SpaceAttributes(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.SpaceAttributes) WorkItemTypeResponse(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.WorkItemTypeResponse) LabelListResponse(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.LabelListResponse) GenericLinksForSpace(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.GenericLinksForSpace) TreeMap(java.util.TreeMap) LabelAttributes(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.LabelAttributes) WorkItemTypeData(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.WorkItemTypeData) Date(java.sql.Date) Area(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.Area) SpaceRelationships(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.SpaceRelationships) SpaceOwnedBy(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.SpaceOwnedBy) IterationListResponse(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.IterationListResponse) UserSingleResponse(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.UserSingleResponse) WorkItemLinkTypeData(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.WorkItemLinkTypeData)

Example 10 with Space

use of org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.Space in project linuxtools by eclipse.

the class OSIORestClient method getSpaceLinkTypes.

public Map<String, String> getSpaceLinkTypes(String spaceId, TaskRepository taskRepository) {
    Space s = null;
    Map<String, String> linkMap = new LinkedHashMap<>();
    try {
        s = getSpaceById(spaceId, taskRepository);
    } catch (CoreException e1) {
        StatusHandler.log(new Status(IStatus.ERROR, OSIORestCore.ID_PLUGIN, // $NON-NLS-1$
        NLS.bind(// $NON-NLS-1$
        "Unexpected error during retrieval of configuration for Task Repository {0}", taskRepository.getRepositoryUrl()), e1));
        return linkMap;
    }
    if (s != null) {
        Map<String, WorkItemLinkTypeData> linkTypes = s.getWorkItemLinkTypes();
        for (WorkItemLinkTypeData linkType : linkTypes.values()) {
            linkMap.put(linkType.getAttributes().getForwardName(), linkType.getId());
            linkMap.put(linkType.getAttributes().getReverseName(), linkType.getId());
        }
    }
    return linkMap;
}
Also used : Space(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.Space) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) CoreException(org.eclipse.core.runtime.CoreException) WorkItemLinkTypeData(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.WorkItemLinkTypeData) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

Space (org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.Space)12 CoreException (org.eclipse.core.runtime.CoreException)6 IStatus (org.eclipse.core.runtime.IStatus)5 WorkItemTypeData (org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.WorkItemTypeData)5 Status (org.eclipse.core.runtime.Status)4 Area (org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.Area)4 Iteration (org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.Iteration)4 WorkItemLinkTypeData (org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.WorkItemLinkTypeData)4 OSIORestClient (org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestClient)3 OSIORestConfiguration (org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestConfiguration)3 Label (org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.Label)3 User (org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.User)3 TestData (org.eclipse.linuxtools.mylyn.osio.rest.test.support.TestData)3 RepositoryLocation (org.eclipse.mylyn.commons.repositories.core.RepositoryLocation)3 TaskAttribute (org.eclipse.mylyn.tasks.core.data.TaskAttribute)3 Test (org.junit.Test)3 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 TreeMap (java.util.TreeMap)2 TreeSet (java.util.TreeSet)2