Profields 4.3.0 Java API

Alejandro Soto August 31, 2015

Hello,

I'm trying to get a list of Project objects with a given Profield value using Profield Java API (see method 

getProjectList) in example below.

For example, the list of project whose Profield called "country" is equals to "Brasil".

 

Has anybody implemented any feature using Java API?

I have some problems configuring my pom.xml because of some required dependecies from profields-4.3.0.jar

Thank you,

Alejandro

 

import com.atlassian.jira.project.Project;
import com.atlassian.jira.user.ApplicationUser;
import com.deiser.jira.profields.api.projectfilter.ProjectQuery;
import com.deiser.jira.profields.api.projectfilter.QueryExpressionBuilderFactory;
import com.deiser.jira.profields.api.projectvalue.ProfieldsFieldValue;
import com.deiser.jira.profields.api.projectvalue.ProjectValueService;
import com.deiser.jira.profields.search.projectquery.expression.QueryExpressionBuilder;
import com.deiser.jira.profields.search.projectquery.expression.element.QueryExpressionClause;
public class TestImpl  {
	private ProjectValueService projectValueService;
	private QueryExpressionBuilderFactory queryExpressionBuilderFactory;
	public ProjectRoleAssignerImpl(ProjectValueService projectValueService,
	        QueryExpressionBuilderFactory queryExpressionBuilderFactory) {
		this.projectValueService = projectValueService;
		this.queryExpressionBuilderFactory = queryExpressionBuilderFactory;
	}

	public void getProjectList(String pql, ApplicationUser user) {
		QueryExpressionBuilder queryExprBuilder = queryExpressionBuilderFactory.getBuilder();
		queryExprBuilder.fromPql(user, pql);
		ProjectQuery projectQuery = queryExprBuilder.getQuery(user);
		QueryExpressionClause query = null;
		List<ProfieldsFieldValue> projectValues = projectValueService.getProjectsByQuery(projectQuery);
		for (ProfieldsFieldValue projectValue : projectValues) {
			Project project = projectValue.getProject();
			System.out.println("ProjectRoleAssignerImpl.getProjectList():Project=" + project.getKey());
		}
	}
}

 

 

2 answers

0 votes
Vasiliy Zverev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 25, 2016

This bug was fied into version 4.3.4.

Kiranped May 11, 2017

How did u resolved this please let me know

geting below error 

[ERROR] Failed to execute goal on project synch-onejira-plugin: Could not resolve dependencies for project com.go2group.jira.plugin:synch-onejira-plugin:atlassian-plugin:2.0.0: Could not find artifact com.deiser:profields:jar:4.1.3 in atlassian-public (https://maven.atlassian.com/repository/public)

0 votes
Vasiliy Zverev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 16, 2015

I also get an empty collection for projectValueService.getValuesForProject(). I create a ticket on deiser issue tracker.

Suggest an answer

Log in or Sign up to answer