Updating Jira Plugin from Version 3 to Version 4, Replacing SearchParameter - plugins

i am pretty new to Jira Development so please be patient
I should upgrade a Plugin that worked with Jira Version 3 to work with Jira Version 4
Most of the thins went pretty well, but now i am kind of stuck
The SearchParameter and the ProjectParameter Class are not available in the new Version and i dont exacly know how to replace them. its really just this few lines of code, where its needed
these Classes are outdated: SearchParameter and ProjectParameter
i looked in the jira doc buts its seems pretty complicated, you would do me a great favor if you could help me
SearchRequest sr = srs.getFilter(ctx, filterId);
...
SearchParameter param = sr.getParam(new ProjectParameter().getName());
...
List columns = columnLayout
.getVisibleColumnLayoutItems(user,
param.getValues(), Collections.EMPTY_LIST);
It would even Help if you could explain what the seccond Line intends
Thanks in advance

I can't help you rewrite the plugin entirely, but I can try help you decipher what those quoted lines of code mean:
SearchRequest sr = srs.getFilter(ctx, filterId);
This line loads a saved SearchRequest with the corresponding filterId.
SearchParameter param = sr.getParam(new ProjectParameter().getName());
This line gets the Project search parameter that was saved in the SearchRequest. As you may know, SearchRequests (or saved filters if you prefer) all you to save a search from JIRA with parameters defined. One possible parameter to define is a ProjectParameter. So if your search is "all issues in project X", then you would have a SearchParameter in your SearchRequest which is a ProjectParameter that knows to search for project X.
List columns = columnLayout
.getVisibleColumnLayoutItems(user,
param.getValues(), Collections.EMPTY_LIST);
This line retrieves the ColumnLayoutItems which are visible to the specified user, for the specified projects of the SearchRequest (by extracting the value from the ProjectParameter of the SearchRequest as retrieved in line 2).
It's a bit unclear what this code is attempting to do without more context, but that's what those lines are doing anyway. You might find the API documentation useful:
http://docs.atlassian.com/jira/3.13/
http://docs.atlassian.com/jira/3.13/com/atlassian/jira/issue/fields/layout/column/ColumnLayout.html

Related

There is a way to use lsp4e for calling language server methods directly?

I'm new to the lsp4e & lsp technologies and as far as I have seen the framework provides almost everything for working with eclipse. However there is a way to use this features at will? i.e I would like to use the LS to get all the functions on a file, I think this will be done with textDocument/documentSymbol but how can I get this using the lsp4e framework?
NOTE:
I checked for SymbolKind and seems it was not the one I was looking for however that input helped me finding a sample of DocumentSymbol
DocumentSymbolParams params = new DocumentSymbolParams(
new TextDocumentIdentifier(documentUri.toString()));
CompletableFuture<List<Either<SymbolInformation, DocumentSymbol>>> symbols =
languageServer.getTextDocumentService().documentSymbol(params);
I checked for SymbolKind and seems it was not the one I was looking for. However that input helped me finding a sample of DocumentSymbol
DocumentSymbolParams params = new DocumentSymbolParams(
new TextDocumentIdentifier(documentUri.toString()));
CompletableFuture<List<Either<SymbolInformation, DocumentSymbol>>> symbols =
languageServer.getTextDocumentService().documentSymbol(params);

Sparx Enterprise Architect DocumentGenerator does not honour TaggedValues on Stereotype or values from SetProjectConstants and ReplaceField

maybe someone can help me on this. I am trying to generate a document via the DocumentGenerator interface. All in all this works well, except that the DocumentGenerator does not replace the Report Constants with actual values (which are defined on the report package stereotype.
This is the general flow of the document creation code (which generally works):
var gen = Repository.CreateDocumentGenerator();
gen.SetProjectConstant("ReportName", "My Project");
gen.NewDocument(string.Empty);
gen.ReplaceField("ReportName", "My Project");
gen.InsertCoverPageDocument(tags[REPORT_COVERPAGE]);
gen.InsertBreak(DocumentBreak.breakPage);
gen.InsertTOCDocument(tags[REPORT_TOC]);
gen.InsertBreak(DocumentBreak.breakPage);
gen.DocumentPackage((int)nativeId, 0, template);
gen.SaveDocument(fileName, DocumentType.dtDOCX);
I tried ReplaceField and SetProjectConstant both and one at a time before and after calls to NewDocument/InsertCoverPageDocument:
Strangely there is one constant that is being replaced: ReportSummary.
When I run the document generator via "F8" all constants are being replaced correctly.
Other project constants are being replaced correctly.
I can reproduce the behaviour on EA v14.1.1429 and v12.0.1215.
Does someone have a hint for further troubleshooting? Thanks in advance!
========== UPDATE ==========
When I use ReplaceField at the end (before the actual call to SaveDocument the following Report Constants get replaced: {ReportTitle} and {ReportName}
I discovered some workaround: when I manually remove the predefined {Report~} constants from the template and re-add them as Project Constants, their values get replaced correctly.
I will examine this further and give an update as
I did some further investigation on this and came to the following conclusion and workaround (as I have received no comments or answers on this):
I deleted all references to ReportConstants in my EA templates and replaced them by ProjectConstants with the same name.
In my code where I want to generate the documentation I (re)set all ProjectConstants with the actual values via SetProjectConstant and additionally added a call to ReplaceField to replace the constants with the actual values.
The previous mentioned calls are inserted directly before the call to SaveDocument document.
tags.ForEach(t =>
{
if (string.IsNullOrWhiteSpace(t.Key)) return;
generator.SetProjectConstant(t.Key, t.Value);
generator.ReplaceField(t.Key, t.Value);
});
generator.SaveDocument(fileName, DocumentType.dtDOCX);
If someone comes up with a better resonse or explanation for the behaviour I am happy to accept this as answer.
I have also found that when you call ReplaceField on these project constants in a CoverPage template, the formatting defined in the template is overwritten. It seems that some of the SetProjectConstant calls actually set the values as you would expect, and the rest do not.. hence the need to call both sets of APIs.

How to trigger a tx_news search using typolink

We recently switched from tt_news to Georg Ringers News extension and I - as a novice typo3 coder - need help fixing some typoscript code that was used to trigger context specific searches using typolink.
The old snippet was
typolink.parameter = 649
typolink.useCacheHash = 1
typolink.additionalParams.current = 1
typolink.additionalParams.wrap = &tx_ttnews[swords]=|
The new parameter needs to be &tx_news_pi1 but swords does not work. I can't find documentation or examples how the search value can be set. I searched the code itself and dumb tried my luck with &tx_news_pi1[search]=| but that just shows the default numerical typo3 error "Oops, an error occurred! Code: 2018020814150924e87636" if something cannot be rendered. BTW: The referenced search result page works fine if called using the search form.
After grabbing through the code try &tx_news_pi1[overwriteDemand][search][subject]=|.
On the target list you need to allow overwriting of the demand in the plugin flexform!
The solution of Thomas works for me even without the [overwriteDemand] using the search result page as target. Thx.
typolink.parameter = 649
typolink.useCacheHash = 1
typolink.additionalParams.current = 1
typolink.additionalParams.wrap = &tx_news_pi1[search][subject]=|
I really would like to know how this could be grabbed from the code. :-) It seems that I have to learn more about php and the underlying data structure - [search][subject] looks like a kind of array which I didn't expect for that type of parameter.

Novacode LineChart type

I have a code that implements a Novacode.LineChart. And the LineChart type which is shown by default is this one:
But I dont want this type of chart, I want it without points, like this:
This is the code where I create the chart:
LineChart c = new LineChart();
c.AddLegend(ChartLegendPosition.Bottom, false);
c.Grouping = Grouping.Stacked;
Anyone knows how can I hide thoose points and show only the lines? Thanks to everyone!!
Your question is shown up while I was searching for the exact same feature. It's probably a bit late but I hope it would be useful for other people in need of this feature.
My so called answer is not more than a few lines of dirty and unmanageable hack so unless you are not in dire need, I do not recommend to follow this way.
I also do not know if is it an approved approach here but I prefer to write the solution step by step so it may help you to grasp the concept and use better methods.
After I have realized that I was unable to use DocX to create a line chart without markers, using currently provided API, I wanted to know what were the differences between actual and desired output. So I saved a copy of .docx file with line chart after I manually edited the chart to expected result.
Before and after the edit
As you may already know, a .docx is a container format and essentially comprised of a few different folders and files. You can open it up with a .zip archive extractor. I used 7-Zip for this task and found chart file at location of /word/charts/chart1.xml but this may differ depending on the file, but you can easily figure it out.
Compared both of chart1.xml files and the difference was, the file without the markers had and extra XML tag with an additional attribute;
<c:marker>
<c:symbol val="none" />
</c:marker>
I had to somehow add this segment of code to chart. I added these up to example code provided by DocX. You can follow up from: DocX/ChartSample.cs at master
This is where the fun begins. Easy part first.
using System.Xml;
using System.Xml.Linq;
using Xceed.Words.NET;
// Create a line chart.
var line_chart = new LineChart();
// Create the data.
var PlaceholderData = ChartData.GenerateRandomDataForLinechart();
// Create and add series
var Series_1 = new Series("Your random chart with placeholder data");
Series_1.Bind(PlaceholderData, "X-Axis", "Y-Axis");
line_chart.AddSeries(Series_1);
// Create a new XmlDocument object and clone the actual chart XML
XmlDocument XMLWithNewTags = new XmlDocument();
XMLWithNewTags.LoadXml(line_chart.Xml.ToString());
I've used XPath Visualizer Tool to determine the XPath query, which is important to know because you can't just add the marker tag to somewhere and expect it to work. Why do I tell this? Because I appended marker tag on a random line and expected it to work. Naive.
// Set a namespace manager with the proper XPath location and alias
XmlNamespaceManager NSMngr = new XmlNamespaceManager(XMLWithNewTags.NameTable);
string XPathQuery = "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser";
string xmlns = "http://schemas.openxmlformats.org/drawingml/2006/chart";
NSMngr.AddNamespace("c", xmlns);
XmlNode NewNode = XMLWithNewTags.SelectSingleNode(XPathQuery, NSMngr);
Now create necessary tags on newly created XML Document object with specified namespace
XmlElement Symbol = XMLWithNewTags.CreateElement("c", "symbol", xmlns);
Symbol.SetAttribute("val", "none");
XmlElement Marker = XMLWithNewTags.CreateElement("c", "marker", xmlns);
Marker.AppendChild(Symbol);
NewNode.AppendChild(Marker);
And we should copy the contents of latest changes to actual XML object. But oops, understandably it is defined as private so it is a read-only object. This is where I thought like "Okay, I've fiddled enough with this. I better find another library" but then decided to go on because reasons.
Downloaded DocX repo, changed this line to
get; set;
recompiled, copied Xceed.Words.NET.dll to both projectfolder/packages and projectfolder/projectname/bin/Debug folder and finally last a few lines were
// Copy the contents of latest changes to actual XML object
line_chart.Xml = XDocument.Parse(XMLWithNewTags.InnerXml);
// Insert chart into document
document.InsertChart(line_chart);
// Save this document to disk.
document.Save();
Is it worth it? I'm not sure but I have learned a few things while working on it. There're probably lots of bad programming practises in this answer so please tell me if you see one. Sorry for meh English.

Anyone have any idea how TabStop works in iText 5.5.0

I'm still trying to learn iText and have a few of the concepts down. However I can't figure out what TabStop is or how to use it. My particular problem is that I want to fill the end of all paragraphs with a bunch of dashes. I believe this is called a TabStop and I see the class in the itext jar but I have no clue on how to use it. I must be searching the wrong thing on google, but I've come up with nothing. The iText in Action book also doesnt seem to even know of the existance of this class so any help is much appreciated!
Please take a look at the ChunkTest class in iText's test suite. It contains several use cases of the tab stop functionality. For instance:
java.util.List<TabStop> tabStopsList = new ArrayList<TabStop>();
tabStopsList.add(new TabStop(100, new DottedLineSeparator()));
tabStopsList.add(new TabStop(200, new LineSeparator(), TabStop.Alignment.CENTER));
tabStopsList.add(new TabStop(300, new DottedLineSeparator(), TabStop.Alignment.RIGHT));
p = new Paragraph(new Chunk("Hello world", f));
p.setTabSettings(new TabSettings(tabStopsList, 50));
addTabs(p, f, 0, "la|la");
ct.addElement(p);
The TabStop functionality was introduced after the iText in Action books were written. They'll be documented in one of the new books.
For another example, see http://developers.itextpdf.com/examples/itext-building-blocks/tabbing-examples