I am trying to get the projectid of my project from JIRA using gradle script.I wrote few methods which basically try to get the JSON output and fetch the project id of that particular project but now i am not able to get the projectId from that. Below is the methods which i am using to get the JSON result. it's working fine but not giving me the exact JSON output.My project Name is TESTPROJECT and id is 12345.I am looking when you have fresh project and need to get the projectid of that project using JIRA request method.I pasted the below JSON output which doesn't have {} "" so not exactly JSON output.Can someone tell me how could I get the project id with below way or am I doing something wrong?
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath 'org.codehaus.groovy.modules.http-builder:http-builder:0.7.1'
classpath 'org.apache.httpcomponents:httpmime:4.2.1'
classpath 'commons-io:commons-io:2.4'
}
}
ext {
jiraURL = "https://test.test.com/"
jiraProject = 'TESTPROJECT'
jiraUser = "test"
jiraPassword = "*****"
}
import groovyx.net.http.HTTPBuilder
import groovyx.net.http.ContentType
def String authHeader() {
String userAndPassword = "${jiraUser}:${jiraPassword}"
String authHeader = 'Basic ' + userAndPassword.getBytes().encodeBase64().toString()
return authHeader
}
/*
* Get the Jira project details
*/
def Map getJiraprojectDetails(String projectName) {
Map json = jiraProjectRequest(
"project/${projectName}",
groovyx.net.http.Method.GET,
null,
'Get JIRA version failure - getJiraprojectDetails()'
)
existingProjectId = json.key.id[0]
if (existingProjectId == null || existingProjectId == 0)
throw new GradleException("Project was not found in JIRA")
return existingProjectId
}
def Map jiraProjectRequest(String path, groovyx.net.http.Method method, Map jsonBody, String failMessage) {
Map jsonResult = null
def jira = new HTTPBuilder("${jiraURL}/rest/api/2/${path}", ContentType.JSON)
jira.request(method) { req ->
headers.'Authorization' = authHeader()
requestContentType = ContentType.JSON
if (body != null)
body = jsonBody
response.success = { resp, json ->
println "$json"
jsonResult = json
println "$jsonResult"
}
response.failure = { resp ->
String message = "${failMessage}: ${resp.status} - ${resp.statusLine.reasonPhrase}"
throw new GradleException(message)
}
}
return jsonResult
}
def void makeNewversion() {
def projectName = "${jiraProject}"
println "$projectName"
projectid = getJiraprojectDetails(projectName)
}
task createJiraVersion() {
doLast {
if (project.hasProperty('createVersion')) {
makeNewversion()
}
}
}
JSON Output
[jira] Response data: -----
[jira] [expand:description,lead,url,projectKeys, self:https://test.test1.com/rest/api/2/project/48352, id:48352, key:TESTPROJECT, description:, lead:[self:https://test.test1.com/rest/api/2/user?username=C56765, key:C56765, name:C56765, avatarUrls:[48x48:https://test.test1.com/secure/useravatar?ownerId=C56765&avatarId=42213, 24x24:https://test.test1.com/secure/useravatar?size=small&ownerId=C56765&avatarId=42213, 16x16:https://test.test1.com/secure/useravatar?size=xsmall&ownerId=h156765&avatarId=42213, 32x32:https://test.test1.com/secure/useravatar?size=medium&ownerId=C56765&avatarId=42213], displayName:karry test, active:true], components:[], issueTypes:[[self:https://test.test1.com/rest/api/2/issuetype/1, id:1, description:A problem which impairs or prevents the functions or performance of the product or its related artifacts. It can be related to software, hardware or both., iconUrl:https://test.test1.com/secure/viewavatar?size=xsmall&avatarId=31313&avatarType=issuetype, name:Defect, subtask:false, avatarId:31313], [self:https://test.test1.com/rest/api/2/issuetype/66, id:66, description:Created by JIRA Software - do not edit or delete. Issue type for a big user story that needs to be broken down., iconUrl:https://test.test1.com/secure/viewavatar?size=xsmall&avatarId=31317&avatarType=issuetype, name:Epic, subtask:false, avatarId:31317], [self:https://test.test1.com/rest/api/2/issuetype/67, id:67, description:Created by JIRA Software - do not edit or delete. Issue type for a user story., iconUrl:https://test.test1.com/secure/viewavatar?size=xsmall&avatarId=31325&avatarType=issuetype, name:Story, subtask:false, avatarId:31325], [self:https://test.test1.com/rest/api/2/issuetype/10600, id:10600, description:, iconUrl:https://test.test1.com/secure/viewavatar?size=xsmall&avatarId=31324&avatarType=issuetype, name:Initiative, subtask:false, avatarId:31324], [self:https://test.test1.com/rest/api/2/issuetype/2, id:2, description:A new feature of the product., iconUrl:https://test.test1.com/secure/viewavatar?size=xsmall&avatarId=31321&avatarType=issuetype, name:New Feature, subtask:false, avatarId:31321], [self:https://test.test1.com/rest/api/2/issuetype/4, id:4, description:An enhancement to an existing feature., iconUrl:https://test.test1.com/secure/viewavatar?size=xsmall&avatarId=31320&avatarType=issuetype, name:Improvement, subtask:false, avatarId:31320], [self:https://test.test1.com/rest/api/2/issuetype/25, id:25, description:A formal request to change an existing, baselined project artifact. , iconUrl:https://test.test1.com/secure/viewavatar?size=xsmall&avatarId=31330&avatarType=issuetype, name:Change Request, subtask:false, avatarId:31330], [self:https://test.test1.com/rest/api/2/issuetype/3, id:3, description:A task that needs to be done., iconUrl:https://test.test1.com/secure/viewavatar?size=xsmall&avatarId=31328&avatarType=issuetype, name:Task, subtask:false, avatarId:31328], [self:https://test.test1.com/rest/api/2/issuetype/26, id:26, description:A risk is an uncertain future event or condition, with a probability of occurrence, and a potential for loss., iconUrl:https://test.test1.com/secure/viewavatar?size=xsmall&avatarId=31318&avatarType=issuetype, name:Risk, subtask:false, avatarId:31318], [self:https://test.test1.com/rest/api/2/issuetype/87, id:87, description:An impediment is something that makes it difficult to do or complete something in a project and thus requires action. It may be a project risks that has occurred and typically represents something upon which a decision and actions are needed. The decision may not necessarily change the scope, schedule or cost of the project but the lack of a decision would affect the schedule., iconUrl:https://test.test1.com/secure/viewavatar?size=xsmall&avatarId=31318&avatarType=issuetype, name:Impediment, subtask:false, avatarId:31318], [self:https://test.test1.com/rest/api/2/issuetype/8, id:8, description:An item discussed in a meeting that requires further action or work., iconUrl:https://test.test1.com/secure/viewavatar?size=xsmall&avatarId=31328&avatarType=issuetype, name:Action Item, subtask:false, avatarId:31328], [self:https://test.test1.com/rest/api/2/issuetype/83, id:83, description:, iconUrl:https://test.test1.com/secure/viewavatar?size=xsmall&avatarId=31314&avatarType=issuetype, name:Root Cause Analysis, subtask:false, avatarId:31314], [self:https://test.test1.com/rest/api/2/issuetype/58, id:58, description:Any issue, solution or improvement learned in a project that should be shared with other people and/or projects., iconUrl:https://test.test1.com/secure/viewavatar?size=xsmall&avatarId=31324&avatarType=issuetype, name:Lesson Learned, subtask:false, avatarId:31324], [self:https://test.test1.com/rest/api/2/issuetype/39, id:39, description:A summary of a meeting including participants, decisions, and resulting actions., iconUrl:https://test.test1.com/secure/viewavatar?size=xsmall&avatarId=39910&avatarType=issuetype, name:Meeting Minutes, subtask:false, avatarId:39910], [self:https://test.test1.com/rest/api/2/issuetype/55, id:55, description:An item for managing a review consisting of one or more review findings., iconUrl:https://test.test1.com/secure/viewavatar?size=xsmall&avatarId=31323&avatarType=issuetype, name:Review, subtask:false, avatarId:31323], [self:https://test.test1.com/rest/api/2/issuetype/43, id:43, description:Used to track and manage Process Compliance and Configuration Audits on a project., iconUrl:https://test.test1.com/secure/viewavatar?size=xsmall&avatarId=42820&avatarType=issuetype, name:Audit, subtask:false, avatarId:42820], [self:https://test.test1.com/rest/api/2/issuetype/63, id:63, description:Used for requesting the approval of a particular work product and collecting approval from multiple individuals., iconUrl:https://test.test1.com/secure/viewavatar?size=xsmall&avatarId=31316&avatarType=issuetype, name:Approval Request, subtask:false, avatarId:31316], [self:https://test.test1.com/rest/api/2/issuetype/5, id:5, description:A task that needs to be done., iconUrl:https://test.test1.com/secure/viewavatar?size=xsmall&avatarId=31328&avatarType=issuetype, name:Sub-Task, subtask:true, avatarId:31328], [self:https://test.test1.com/rest/api/2/issuetype/35, id:35, description:An item discussed in a meeting that requires further action or work., iconUrl:https://test.test1.com/secure/viewavatar?size=xsmall&avatarId=31328&avatarType=issuetype, name:Action Item (Sub-Issue), subtask:true, avatarId:31328], [self:https://test.test1.com/rest/api/2/issuetype/56, id:56, description:A defect, question, suggestion or other issue resulting from the review of a document or other artifact. , iconUrl:https://test.test1.com/secure/viewavatar?size=xsmall&avatarId=31323&avatarType=issuetype, name:Review Finding, subtask:true, avatarId:31323], [self:https://test.test1.com/rest/api/2/issuetype/62, id:62, description:, iconUrl:https://test.test1.com/images/icons/issuetypes/documentation.png, name:Mitigation Plan, subtask:true], [self:https://test.test1.com/rest/api/2/issuetype/61, id:61, description:An issue (non-compliance, recommendation) found during an audit., iconUrl:https://test.test1.com/secure/viewavatar?size=xsmall&avatarId=31323&avatarType=issuetype, name:Audit Finding, subtask:true, avatarId:31323], [self:https://test.test1.com/rest/api/2/issuetype/64, id:64, description:A sub-issue type used for capturing the approval (or disapproval) of an individual for a particular work product., iconUrl:https://test.test1.com/secure/viewavatar?size=xsmall&avatarId=31316&avatarType=issuetype, name:Approval, subtask:true, avatarId:31316]], assigneeType:PROJECT_LEAD, versions:[[self:https://test.test1.com/rest/api/2/version/98423, id:98423, name:TCD 1.2.3, archived:false, released:false, projectId:48352]], name:Test PAAS, roles:[CCB:https://test.test1.com/rest/api/2/project/48352/role/10020, L1 Support:https://test.test1.com/rest/api/2/project/48352/role/10050, Developers:https://test.test1.com/rest/api/2/project/48352/role/10001, Approvers:https://test.test1.com/rest/api/2/project/48352/role/10052, Administrators:https://test.test1.com/rest/api/2/project/48352/role/10002, Watcher:https://test.test1.com/rest/api/2/project/48352/role/10030, Bulkcloners:https://test.test1.com/rest/api/2/project/48352/role/10070, Testers:https://test.test1.com/rest/api/2/project/48352/role/10010, Users:https://test.test1.com/rest/api/2/project/48352/role/10000, L2 Support:https://test.test1.com/rest/api/2/project/48352/role/10051], avatarUrls:[48x48:https://test.test1.com/secure/projectavatar?avatarId=39413, 24x24:https://test.test1.com/secure/projectavatar?size=small&avatarId=39413, 16x16:https://test.test1.com/secure/projectavatar?size=xsmall&avatarId=39413, 32x32:https://test.test1.com/secure/projectavatar?size=medium&avatarId=39413], projectCategory:[self:https://test.test1.com/rest/api/2/projectCategory/18032, id:18032, name:Solutions, description:TO-12179], projectTypeKey:software]
Below is the code to get the project id
/*
* Get the Jira project ID for a project like 'ABC'
*/
def int getJiraProjectid(String jiraProject) {
int existingProjectId = 0
def json = [jiraprojectRequest()]
json.each {
existingProjectId = it."id".toInteger()
//println "$existingVersionId"
}
if (existingProjectId == 0)
throw new GradleException("Existing project ${jiraProject} was not found in JIRA")
return existingProjectId
}
def Map jiraprojectRequest() {
Map jsonResultList = null
def jira = new HTTPBuilder("${jiraURL}/rest/api/2/project/${jiraProject}", ContentType.JSON)
jira.request(groovyx.net.http.Method.GET) { req ->
headers.'Authorization' = authHeader()
response.success = { resp, json ->
project.getLogger().info('[jira] Response data: -----')
project.getLogger().info("[jira] $json")
project.getLogger().info('\n--------------------')
jsonResultList = json
}
response.failure = { resp ->
throw new GradleException("Get JIRA versions failure - jiraGetVersions(): ${resp.status} - ${resp.statusLine.reasonPhrase}")
}
}
return jsonResultList
}
I'm trying to connect to SAP ECC 6.0 using JCo. I'm following this tutorial. However, there is a Note saying:
For this example the destination configuration is stored in a file that is called by the program. In practice you should avoid this for security reasons.
And that is reasonable and understood. But, there is no explenation how to set up secure destination provider.
I found solution in this thread that created custom implementation of DestinationDataProvider and that works on my local machine. But when I deploy it on Portal I get an error saying that there is already registered DestinationDataProvider.
So my question is:
How to store destination data in SAP Java EE application?
Here is my code to further clarify what I'm trying to do.
public static void main(String... args) throws JCoException {
CustomDestinationProviderMap provider = new CustomDestinationProviderMap();
com.sap.conn.jco.ext.Environment.registerDestinationDataProvider(provider);
Properties connectProperties = new Properties();
connectProperties.setProperty(DestinationDataProvider.JCO_ASHOST, "host.sap.my.domain.com");
connectProperties.setProperty(DestinationDataProvider.JCO_SYSNR, "00");
connectProperties.setProperty(DestinationDataProvider.JCO_CLIENT, "100");
connectProperties.setProperty(DestinationDataProvider.JCO_USER, "user");
connectProperties.setProperty(DestinationDataProvider.JCO_PASSWD, "password");
connectProperties.setProperty(DestinationDataProvider.JCO_LANG, "en");
provider.addDestination(DESTINATION_NAME1, connectProperties);
connect();
}
public static void connect() throws JCoException {
String FUNCTION_NAME = "BAPI_EMPLOYEE_GETDATA";
JCoDestination destination = JCoDestinationManager.getDestination(DESTINATION_NAME1);
JCoContext.begin(destination);
JCoFunction function = destination.getRepository().getFunction(FUNCTION_NAME);
if (function == null) {
throw new RuntimeException(FUNCTION_NAME + " not found in SAP.");
}
//function.getImportParameterList().setValue("EMPLOYEE_ID", "48");
function.getImportParameterList().setValue("FSTNAME_M", "ANAKIN");
function.getImportParameterList().setValue("LASTNAME_M", "SKYWALKER");
try {
function.execute(destination);
} catch (AbapException e) {
System.out.println(e.toString());
return;
}
JCoTable table = function.getTableParameterList().getTable("PERSONAL_DATA");
for (int i = 0; i < table.getNumRows(); i++) {
table.setRow(i);
System.out.println(table.getString("PERNO") + '\t' + table.getString("FIRSTNAME") + '\t' + table.getString("LAST_NAME")
+'\t' + table.getString("BIRTHDATE")+'\t' + table.getString("GENDER"));
}
JCoContext.end(destination);
}
Ok, so I got this up and going and thought I'd share my research.
You need to add your own destination in Portal. To achieve that you need to go to NetWeaver Administrator, located at: host:port/nwa. So it'll be something like sapportal.your.domain.com:50000/nwa.
Then you go to Configuration-> Infrastructure-> Destinations and add your destination there. You can leave empty most of the fields like Message Server. The important part is Destination name as it is how you will retrieve it and destination type which should be set to RFC Destination in my case. Try pinging your newly created destination to check if its up and going.
Finally you should be able to get destination by simply calling: JCoDestination destination = JCoDestinationManager.getDestination(DESTINATION_NAME); as it is added to your Portal environment and managed from there.
Take a look at the CustomDestinationDataProvider in the JCo examples of the Jco connector download. The important parts are:
static class MyDestinationDataProvider implements DestinationDataProvider
...
com.sap.conn.jco.ext.Environment.registerDestinationDataProvider(new MyDestinationDataProvider());
Then you can simply do:
instance = JCoDestinationManager.getDestination(DESTINATION_NAME);
Btw. you may also want to check out http://hibersap.org/ as they provide nice ways to store the config as well.
I have downloaded the indexes generated for Maven Central from http://mirrors.ibiblio.org/pub/mirrors/maven2/dot-index/nexus-maven-repository-index.gz
I would like to list the artifacts information from these index files (groupId, artifactId, version for example). I have read that there is a high level API for that. It seems that I have to use the following maven dependency. However, I don't know what is the entry point to use (which class?) and how to use it to access those files:
<dependency>
<groupId>org.sonatype.nexus</groupId>
<artifactId>nexus-indexer</artifactId>
<version>3.0.4</version>
</dependency>
Take a peek at https://github.com/cstamas/maven-indexer-examples project.
In short: you dont need to download the GZ/ZIP (new/legacy format) manually, it will indexer take care of doing it for you (moreover, it will handle incremental updates for you too, if possible).
GZ is the "new" format, independent of Lucene index-format (hence, independent of Lucene version) containing data only, while the ZIP is "old" format, which is actually plain Lucene 2.4.x index zipped up. No data content change happens currently, but is planned in future.
As I said, there is no data content difference between two, but some fields (like you noticed) are Indexed but not stored on index, hence, if you consume the ZIP format, you will have them searchable, but not retrievable.
The https://github.com/cstamas/maven-indexer-examples is obsolete. And the build fails (tests do not pass).
The Nexus Indexer has moved along and included the examples too:
https://github.com/apache/maven-indexer/tree/master/indexer-examples
That builds, and the code works.
Here is a simplified version if you want to roll your own:
Maven:
<dependencies>
<dependency>
<groupId>org.apache.maven.indexer</groupId>
<artifactId>indexer-core</artifactId>
<version>6.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<!-- For ResourceFetcher implementation, if used -->
<dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-http-lightweight</artifactId>
<version>2.3</version>
<scope>compile</scope>
</dependency>
<!-- Runtime: DI, but using Plexus Shim as we use Wagon -->
<dependency>
<groupId>org.eclipse.sisu</groupId>
<artifactId>org.eclipse.sisu.plexus</artifactId>
<version>0.2.1</version>
</dependency>
<dependency>
<groupId>org.sonatype.sisu</groupId>
<artifactId>sisu-guice</artifactId>
<version>3.2.4</version>
</dependency>
Java:
public IndexToGavMappingConverter(File dataDir, String id, String url)
throws PlexusContainerException, ComponentLookupException, IOException
{
this.dataDir = dataDir;
// Create Plexus container, the Maven default IoC container.
final DefaultContainerConfiguration config = new DefaultContainerConfiguration();
config.setClassPathScanning( PlexusConstants.SCANNING_INDEX );
this.plexusContainer = new DefaultPlexusContainer(config);
// Lookup the indexer components from plexus.
this.indexer = plexusContainer.lookup( Indexer.class );
this.indexUpdater = plexusContainer.lookup( IndexUpdater.class );
// Lookup wagon used to remotely fetch index.
this.httpWagon = plexusContainer.lookup( Wagon.class, "http" );
// Files where local cache is (if any) and Lucene Index should be located
this.centralLocalCache = new File( this.dataDir, id + "-cache" );
this.centralIndexDir = new File( this.dataDir, id + "-index" );
// Creators we want to use (search for fields it defines).
// See https://maven.apache.org/maven-indexer/indexer-core/apidocs/index.html?constant-values.html
List<IndexCreator> indexers = new ArrayList();
// https://maven.apache.org/maven-indexer/apidocs/org/apache/maven/index/creator/MinimalArtifactInfoIndexCreator.html
indexers.add( plexusContainer.lookup( IndexCreator.class, "min" ) );
// https://maven.apache.org/maven-indexer/apidocs/org/apache/maven/index/creator/JarFileContentsIndexCreator.html
//indexers.add( plexusContainer.lookup( IndexCreator.class, "jarContent" ) );
// https://maven.apache.org/maven-indexer/apidocs/org/apache/maven/index/creator/MavenPluginArtifactInfoIndexCreator.html
//indexers.add( plexusContainer.lookup( IndexCreator.class, "maven-plugin" ) );
// Create context for central repository index.
this.centralContext = this.indexer.createIndexingContext(
id + "Context", id, this.centralLocalCache, this.centralIndexDir,
url, null, true, true, indexers );
}
final IndexSearcher searcher = this.centralContext.acquireIndexSearcher();
try
{
final IndexReader ir = searcher.getIndexReader();
Bits liveDocs = MultiFields.getLiveDocs(ir);
for ( int i = 0; i < ir.maxDoc(); i++ )
{
if ( liveDocs == null || liveDocs.get( i ) )
{
final Document doc = ir.document( i );
final ArtifactInfo ai = IndexUtils.constructArtifactInfo( doc, this.centralContext );
if (ai == null)
continue;
if (ai.getSha1() == null)
continue;
if (ai.getSha1().length() != 40)
continue;
if ("javadoc".equals(ai.getClassifier()))
continue;
if ("sources".equals(ai.getClassifier()))
continue;
out.append(StringUtils.lowerCase(ai.getSha1())).append(' ');
out.append(ai.getGroupId()).append(":");
out.append(ai.getArtifactId()).append(":");
out.append(ai.getVersion()).append(":");
out.append(StringUtils.defaultString(ai.getClassifier()));
out.append('\n');
}
}
}
finally
{
this.centralContext.releaseIndexSearcher( searcher );
}
We use this in the Windup project - JBoss migration tool.
The legacy zip index is a simple lucene index. I was able to open it with Luke
and write some simple lucene code to dump out the headers of interest ("u" in this case)
import org.apache.lucene.document.Document;
import org.apache.lucene.search.IndexSearcher;
public class Dumper {
public static void main(String[] args) throws Exception {
IndexSearcher searcher = new IndexSearcher("c:/PROJECTS/Test/index");
for (int i = 0; i < searcher.maxDoc(); i++) {
Document doc = searcher.doc(i);
String metadata = doc.get("u");
if (metadata != null) {
System.out.println(metadata);
}
}
}
}
Sample output ...
org.ioke|ioke-lang-lib|P-0.4.0-p11|NA
org.jboss.weld.archetypes|jboss-javaee6-webapp|1.0.1.CR2|sources|jar
org.jboss.weld.archetypes|jboss-javaee6-webapp|1.0.1.CR2|NA
org.nutz|nutz|1.b.37|javadoc|jar
org.nutz|nutz|1.b.37|sources|jar
org.nutz|nutz|1.b.37|NA
org.openengsb.wrapped|com.google.gdata|1.41.5.w1|NA
org.openengsb.wrapped|openengsb-wrapped-parent|6|NA
There may be better ways to achieve this though ...
For the records, there is now a tool to extract and export maven indexes as text files: the Maven index exporter. It's available as a Docker image and no code is required.
It basically downloads all .gz index files, extracts the indexes using maven-indexer cli and exports them to a text file with clue. It has been tested on Maven Central and works on many other Maven repositories.
I am trying hard to implement a charting extension to an app that i am developing : so my problem is that I have written some code (the boiler plate one) for doing this in BIRT.
At some place in the code, I have to link the dataset to a series and link the series to a seriesdefinition object which finally will be attached to the charts seriesDefinitions like this
RadarSeries radarSeries = RadarSeriesImpl.create();
radarSeries.setDataSet(numberDataValues);
radarSeries.setSeriesIdentifier("Number data values");
radarSeries.getLabel().setVisible(true);
where numberDataValues is an array of doubles. Then I create my seriesDefinition :
SeriesDefinition seriesDefinition = SeriesDefinitionImpl.create();
seriesDefinition.getSeriesPalette().shift(0);
But then, here comes the time when I have to LINK my radarSeries to the seriesDefinition like this :
seriesDefinition.getSeriesDefinitions().add(radarSeries);
THE PROBLEM : I don't have the getSeriesDefinitions() method when trying to call it from code (doing a Ctrl+Space in Eclipse).
Needless to say that I can't call the getSeriesDefinitions() method on myChart object :
myChart.getSeriesDefinitions().add(seriesDefinition);
FOR YOUR INFORMATION : I have included my birt jars manually in my local maven repository and the details of these dependencies are :
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>engineapi</artifactId>
<version>${birtVersion}</version>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>coreapi</artifactId>
<version>${birtVersion}</version>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>scriptapi</artifactId>
<version>${birtVersion}</version>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>chartengineapi</artifactId>
<version>${birtVersion}</version>
</dependency>
where ${birtVersion} = 2.6.2
here is a link to the official example of the 2.6.2 release of birt about RadarChart : Radar chart official release example
Can somebody help me ? I really can't believe I didn't found out how to do this in a 3days google search session : that not serious! ... given its popularity and its power, I think they should have invested more effort in the documentation ...
#Birt guyz (if any) > sorry to be so dramatic guys, but I really think that the doc side really sucks ... I hope to be able to help you on this (really, I do)
Here is the code :
public String drawChart() {
// Birt Vars
IDeviceRenderer iDeviceRenderer = null;
IDisplayServer iDisplayServer = null;
RunTimeContext context;
Chart chart = null;
// Birt Platform configuration
PlatformConfig platformConfig = new PlatformConfig();
platformConfig.setProperty("STANDALONE", true);
// Creating Chart Engine
ChartEngine chartEngine = ChartEngine.instance(platformConfig);
IGenerator iGenerator = chartEngine.getGenerator();
if(iGenerator == null)
System.out.println("IGenerator NULL");
else
System.out.println("IGenerator NOT NULL");
try {
// iDeviceRenderer = chartEngine.getRenderer("dv.PNG");
iDeviceRenderer = chartEngine.getRenderer("dv.GIF");
iDisplayServer = iDeviceRenderer.getDisplayServer();
} catch (Exception e) {
e.printStackTrace();
}
// Creating Chart
ChartWithoutAxes radarChart = ChartWithoutAxesImpl.create( );
radarChart.setDimension( ChartDimension.TWO_DIMENSIONAL_LITERAL );
radarChart.setType(Radar.TYPE_LITERAL); //$NON-NLS-1$
radarChart.setSubType( "Standard Radar Chart" ); //$NON-NLS-1$
// Plot
radarChart.setSeriesThickness( 10 );
// Legend
Legend lg = radarChart.getLegend( );
lg.getOutline( ).setVisible( true );
// Title
radarChart.getTitle( )
.getLabel( )
.getCaption( )
.setValue( "Radar Chart" );//$NON-NLS-1$
try {
if(radarChart != null)
System.out.println("RADAR CHART NOT NULL");
else
System.out.println("RADAR CHART NULL!!!");
// PREPARE PHASE
context = Generator.instance().prepare(radarChart, null, null, ULocale.getDefault());
if(context == null)
System.out.println("CONTEXT NULL ");
else
System.out.println("CONTEXT NOT NULL");
//BIND PHASE : fetch data from DB
NumberDataSet numberDataValues = NumberDataSetImpl.create( new double[]{
54, 21, 75, 91, 37
} );
// Radar series
RadarSeries radarSeries = RadarSeriesImpl.create();
radarSeries.setDataSet(numberDataValues);
radarSeries.setSeriesIdentifier("Number data values");
radarSeries.getLabel().setVisible(true);
SeriesDefinitionImpl seriesDefinition = (SeriesDefinitionImpl) SeriesDefinitionImpl.create();
seriesDefinition.getSeriesPalette().shift(0);
// ERROR HERE : can't call the method
seriesDefinition.getSeriesDefinitions()
// RENDERING PHASE
if(iDisplayServer == null)
System.out.println("DISPLAY SERVER NULL");
else
System.out.println("DISPLAY SERVER NOT NULL");
GeneratedChartState generatedChartState = iGenerator.build(iDisplayServer, radarChart, null, null, context);
iGenerator.render(iDeviceRenderer, generatedChartState);
} catch (Exception e) {
e.printStackTrace();
}
}
EDIT + SOLUTION
Sorry for the delay : I should have posted this answer earlier to mark this question as solved.
Just use the RCP report designer to create your report document. Copy ReportEngine/lib/*jars to your /WEB-INF/lib; also create a platform/ directory under WEB-INF/ and copy BIRT ReportEngine configuration/ and plugins/ directories under the newly created WEB-INF/platform/ folder. Now with the *.rptdesign file that you have created in your BIRT RCP designer tool, you will have to use the BIRT API which will allow you to interact with your report...
Sorry for the delay : I should have posted this answer earlier to mark this question as solved.
Just use the RCP report designer to create your report document.
Then copy ReportEngine/lib/*jars to your /WEB-INF/lib; also create a platform/ directory under WEB-INF/ and copy BIRT ReportEngine configuration/ and plugins/ directories under the newly created WEB-INF/platform/ folder.
Now with the *.rptdesign file that you have created in your BIRT RCP designer tool, you will have to use the BIRT API which will allow you to interact with your report...