use of org.eclipse.sw360.datahandler.thrift.projects.Project in project sw360portal by sw360.
the class FossologyAwarePortlet method serveGetSendableReleases.
protected void serveGetSendableReleases(ResourceRequest request, ResourceResponse response) throws PortletException, IOException {
String projectId = request.getParameter(PROJECT_ID);
User user = UserCacheHolder.getUserFromRequest(request);
try {
putReleasesAndProjectIntoRequest(request, projectId, user);
include("/html/projects/ajax/sendableTable.jsp", request, response, PortletRequest.RESOURCE_PHASE);
} catch (TException e) {
log.error("Problem with project client", e);
throw new PortletException(e);
}
}
use of org.eclipse.sw360.datahandler.thrift.projects.Project in project sw360portal by sw360.
the class LinkedReleasesAndProjectsAwarePortlet method serveLoadLinkedProjectsRows.
protected void serveLoadLinkedProjectsRows(ResourceRequest request, ResourceResponse response) throws PortletException, IOException {
final User user = UserCacheHolder.getUserFromRequest(request);
String branchId = request.getParameter(PARENT_BRANCH_ID);
request.setAttribute(PARENT_BRANCH_ID, branchId);
if (branchId != null) {
String id = branchId.split("_")[0];
try {
ProjectService.Iface client = thriftClients.makeProjectClient();
Project project = client.getProjectById(id, user);
List<ProjectLink> mappedProjectLinks = createLinkedProjects(project, user);
request.setAttribute(PROJECT_LIST, mappedProjectLinks);
} catch (TException e) {
log.error("Error getting projects!", e);
throw new PortletException("cannot get projects", e);
}
} else {
List<ProjectLink> mappedProjectLinks = createLinkedProjects(new Project(), user);
request.setAttribute(PROJECT_LIST, mappedProjectLinks);
}
request.setAttribute(PortalConstants.PARENT_SCOPE_GROUP_ID, request.getParameter(PortalConstants.PARENT_SCOPE_GROUP_ID));
include("/html/utils/ajax/linkedProjectsRows.jsp", request, response, PortletRequest.RESOURCE_PHASE);
}
use of org.eclipse.sw360.datahandler.thrift.projects.Project in project sw360portal by sw360.
the class ProjectModerationRequestGenerator method setAdditionsAndDeletions.
@Override
public ModerationRequest setAdditionsAndDeletions(ModerationRequest request, Project updateProject, Project actualProject) {
updateDocument = updateProject;
actualDocument = actualProject;
documentAdditions = new Project();
documentDeletions = new Project();
// required fields:
documentAdditions.setName(updateProject.getName());
documentAdditions.setId(actualProject.getId());
documentDeletions.setName(actualProject.getName());
documentDeletions.setId(actualProject.getId());
for (Project._Fields field : Project._Fields.values()) {
if (Project.metaDataMap.get(field).valueMetaData.type == TType.BOOL || Project.metaDataMap.get(field).valueMetaData.type == TType.I32) {
if (actualDocument.getFieldValue(field) != updateDocument.getFieldValue(field)) {
documentAdditions.setFieldValue(field, updateDocument.getFieldValue(field));
documentDeletions.setFieldValue(field, actualDocument.getFieldValue(field));
}
} else if (actualProject.getFieldValue(field) == null) {
documentAdditions.setFieldValue(field, updateProject.getFieldValue(field));
} else if (updateProject.getFieldValue(field) == null) {
documentDeletions.setFieldValue(field, actualProject.getFieldValue(field));
} else if (!actualProject.getFieldValue(field).equals(updateProject.getFieldValue(field))) {
switch(field) {
// ignored fields and concluded fields
case PERMISSIONS:
case DOCUMENT_STATE:
case RELEASE_CLEARING_STATE_SUMMARY:
break;
case ATTACHMENTS:
dealWithAttachments(Project._Fields.ATTACHMENTS);
break;
case LINKED_PROJECTS:
dealWithEnumMap(Project._Fields.LINKED_PROJECTS, ProjectRelationship.class);
break;
case RELEASE_ID_TO_USAGE:
dealWithStringKeyedMap(Project._Fields.RELEASE_ID_TO_USAGE);
break;
case ROLES:
dealWithCustomMap(Project._Fields.ROLES);
break;
default:
dealWithBaseTypes(field, Project.metaDataMap.get(field));
}
}
}
request.setProjectAdditions(documentAdditions);
request.setProjectDeletions(documentDeletions);
return request;
}
use of org.eclipse.sw360.datahandler.thrift.projects.Project in project sw360portal by sw360.
the class ProjectHandler method getProjectById.
// //////////////////////////
// GET INDIVIDUAL OBJECTS //
// //////////////////////////
@Override
public Project getProjectById(String id, User user) throws TException {
assertUser(user);
assertId(id);
Project project = handler.getProjectById(id, user);
assertNotNull(project);
return project;
}
use of org.eclipse.sw360.datahandler.thrift.projects.Project in project sw360portal by sw360.
the class ProjectHandler method getLinkedProjectsById.
@Override
public List<ProjectLink> getLinkedProjectsById(String id, boolean deep, User user) throws TException {
assertId(id);
Project project = getProjectById(id, user);
return getLinkedProjectsOfProject(project, deep, user);
}
Aggregations