Google Spreadsheets API removes underscore - java

I'm using Google Spreadsheets API with a list-based feed. When I get the tags values - with getCustomElements().getTags() - I get them without underscore. For example: parent_id becomes parentid.
Anyone knows how to solve this?

I have only been able to get "true" column names by using the cell feed.
<?php
// given $spreadsheetKey, $worksheetId, $spreadsheetService...
$qry = new Zend_Gdata_Spreadsheets_CellQuery();
$qry->setSpreadsheetKey($spreadsheetKey);
$qry->setWorksheetId($worksheetId);
$qry->setMinCol(1);
$qry->setMaxCol(null);
$qry->setMinRow(1);
$qry->setMaxRow(1);
$cellFeed = $spreadsheetService->getCellFeed($qry);
foreach ($cellFeed as $cellEntry)
{
$columnNumber = $cellEntry->cell->getColumn();
$columnLabel = $cellEntry->cell->getText();
echo "Column $columnNumber is labeled $columnLabel<br>\n";
}
?>

Related

Regex for Facebook Photo ID from a URL in Java

I’m trying to figure out a regex expression in Java to obtain the photo's id for this facebook url:
https://www.facebook.com/566162426788268/photos/a.566209603450217.1073741828.566162426788268/1214828765254961/?type=3&theater
I have come up with the solution
\w++(?=/\?)
but it does not work.
Help appreciated!
In Java you could look for "\w+(?=\/\?)" and since there is no match groups extracted you get group 0.
Example snippet:
String photoIdPatternAsString = "\\w+(?=\\/\\?)";
Matcher postIdMatcher = Pattern.compile(photoIdPatternAsString).matcher(postUrl);
if (postIdMatcher.find()) {
postId = postIdMatcher.group(0);
} else throw new IOException();

Change image object on template using Brother print Android SDK

I have set up label printing from our app using the b-PAC Android SDK (Java). Using the code below I can replace the text from my template with what I want.
// Start creating P-touch Template command print data
Boolean val= myPrinter.startPTTPrint(6, null);
Log.i("print", "startPTTPrint "+val);
// Replace text
myPrinter.replaceText("abcde");
// Trasmit P-touch Template command print data
PrinterStatus status=myPrinter.flushPTTPrint();
I am now trying to replace an image object within the template. I know it can be done in VBScript using:
bpac.Object ob = doc.GetObject("Photo");
ob.SetData(0, #"C:\Photo\635466380534236711.png", 4);
I can't find any Java examples of this within the b-PAC 3.1 SDK help guide and I have only just began coding in Java so I am very much a novice.
Does anyone have experience with the Brother SDK/Java who can point me in the right direction?
Thanks!
I got this working
Basically I have a template that I copy to an new file on which I make the changes
The image object in the template is called imgPart, the other objects are textblocks
Dim m_partNum As String = "12345"
Dim m_PartName As String = "Plate Special 1 x 2" & vbCrLf & "4 Studs"
Dim m_PartImage As String = "c:\Danny\myLego\Labels\PartImages\3033.png"
Dim m_template As String = "c:\Danny\myLego\Templates\PRINTME.lbx"
Dim m_target As String = "c:\Danny\myLego\Templates\" & m_partNum & ".lbx"
Dim doc As bpac.DocumentClass = New bpac.DocumentClass
Try
File.Copy(m_template, m_target, vbTrue)
If doc.Open(m_target) <> False Then
doc.GetObject("imgPart").SetData(0, m_PartImage, 4)
doc.GetObject("txtPartName").Text = m_PartName
doc.GetObject("txtPartNum").Text = m_partNum
doc.Save()
doc.Close()
Else
MsgBox("Open Error on Receipt with error")
End If
Catch ex As Exception
MsgBox("Error occurred : " & ex.ToString)
End Try

How to restart page number from 1 in different group of BIRT report

Backgroud:
Use Java + BIRT to generate report.
Generate report in viewer and allow user to choose to export it to different format (pdf, xls, word...).
All program are in "Layout", no program in "Master Page".
Have 1 "Data Set". The fields in "Layout" refer to this DS.
There is Group in "Layout", gropu by one field.
In "Group Header", I create one cell to use as page number. "Page : MyPageNumber".
"MyPageNumber" is a field I define which would +1 in Group Header.
Problem:
When I use 1st method to generate report, "MyPageNumber" could not show correctly. Because group header only load one time for each group. It would always show 1.
Question:
As I know there is "restart page number in group" in Crystal report. How to restart page in BIRT?
I want to show data of different group in 1 report file, and the page number start from 1 for each group.
You can do it with BIRT reports using page variables. For example:
Add 2 page variables... Group_page, Group_name.
Add 1 report variable... Group_total_page.
In the report beforeFactory add the script:
prevGroupKey = "";
groupPageNumber = 1;
reportContext.setGlobalVariable("gGROUP_NAME", "");
reportContext.setGlobalVariable("gGROUP_PAGE", 1);
In the report onPageEnd add the script:
var groupKey = currGroup;
var prevGroupKey = reportContext.getGlobalVariable("gGROUP_NAME");
var groupPageNumber = reportContext.getGlobalVariable("gGROUP_PAGE");
if( prevGroupKey == null ){
prevGroupKey = "";
}
if (prevGroupKey == groupKey)
{
if (groupPageNumber != null)
{
groupPageNumber = parseInt(groupPageNumber) + 1;
}
else {
groupPageNumber = 1;
}
}
else {
groupPageNumber = 1;
prevGroupKey = groupKey;
}
reportContext.setPageVariable("GROUP_NAME", groupKey);
reportContext.setPageVariable("GROUP_PAGE", groupPageNumber);
reportContext.setGlobalVariable("gGROUP_NAME", groupKey);
reportContext.setGlobalVariable("gGROUP_PAGE", groupPageNumber);
var groupTotalPage = reportContext.getPageVariable("GROUP_TOTAL_PAGE");
if (groupTotalPage == null)
{
groupTotalPage = new java.util.HashMap();
reportContext.setPageVariable("GROUP_TOTAL_PAGE", groupTotalPage);
}
groupTotalPage.put(groupKey, groupPageNumber);
In a master page onRender script add the following script:
var totalPage = reportContext.getPageVariable("GROUP_TOTAL_PAGE");
var groupName = reportContext.getPageVariable("GROUP_NAME");
if (totalPage != null)
{
this.text = java.lang.Integer.toString(totalPage.get(groupName));
}
In the table group header onCreate event, add the following script, replacing 'COUNTRY' with the name of the column that you are grouping on:
currGroup = this.getRowData().getColumnValue("COUNTRY");
In the master page add a grid to the header or footer and add an autotext variable for Group_page and Group_total_page. Optionally add the page variable for the Group_name as well.
Check out these links for more information about BIRT page variables:
https://books.google.ch/books?id=aIjZ4FYJOQkC&pg=PA85&lpg=PA85&dq=birt+change+autotext&source=bl&ots=K0nCmF2hrD&sig=CBOr_otRW0B72sZoFS7LC_1Mrz4&hl=en&sa=X&ei=ZKNAVcnuLYLHsAXRmIHoCw&ved=0CEoQ6AEwBQ#v=onepage&q=birt%20change%20autotext&f=false
https://www.youtube.com/watch?v=lw_k1qHY_gU
http://www.eclipse.org/birt/phoenix/project/notable2.5.php#jump_4
https://bugs.eclipse.org/bugs/show_bug.cgi?id=316173
http://www.eclipse.org/forums/index.php/t/575172/
Alas, this is not supported with BIRT.
That's probably not the answer you've hoped for, but it's the truth.
This is one of the very few aspects where BIRT is way behind other report generator tools.
However, depending on how you have BIRT integrated into your environment, a workaround approach is possible for PDF export that we use in our solution with great success.
The idea is to let BIRT generate a PDF outline based on the grouping.
And the BIRT report creates information in the ReportContext about where and how it wants the page numbers to be displayed.
After BIRT generated the PDF, a custom PDFPostProcessor uses the PDF outline and the information from the ReportContext to add the page numbers with iText.
If this work-around is viable for you, feel free to contact me.

How can I retrieve DBObjects that contains a substring of a search-word?

I am using MongoDB with Java Driver (http://tinyurl.com/dyjxz8k). In my application I want it to be possible to give results that contains a substring of the users search-term. The method looks like this:
*searchlabel = the name of a field
*searchTerm = the users searchword
private void dbSearch(String searchlabel, String searchTerm){
if(searchTerm != null && (searchTerm.length() > 0)){
DBCollection coll = db.getCollection("MediaCollection");
BasicDBObject query = new BasicDBObject(searchlabel, searchTerm);
DBCursor cursor = coll.find();
cursor = coll.find(query);
try {
while(cursor.hasNext()) {
System.out.println(cursor.next());
//view.showResult(cursor.next());
}
} finally {
cursor.close();
}
}
}
Does anybody have any idea about how I can solve this? Thanks in advance =) And a small additional question: How can I handle the DBObjects according to presentation in (a JLabel in) view?
For text-searching in Mongo, there are two options:
$regex operator - however unless you have a simple prefix regexp, queries won't use an index, and will result in a full scan, which usually is slow
In Mongo 2.4, a new text index has been introduced. A text query will split your query into words, and do an or-search for documents including any of the words. Text indexes also eliminate some stop-words and have simple stemming for some languages (see the docs).
If you are looking for a more advanced full-text search engine, with more powerful tokenising, stemming, autocomplete etc., maybe a better fit would be e.g. ElasticSearch.
I use this method in the mongo console to search with a regular expression in JavaScript:
// My name to search for
var searchWord = "alex";
// Construct a query with a simple /^alex$/i regex
var query = {};
query.animalName = new RegExp("^"+searchWord+"$","i");
// Perform find operation
var lionsNamedAlex = db.lions.find(query);

jericho Html parser error in jsp page

I have write code as
String sourceUrlString="http://some url";
Source source=new Source(new URL(sourceUrlString));
Element INFORM = source.getElementById("main").getAllElementsByClass("game").get(i-1);
String INFORM = INFORM.replaceAll("\\s",""); //shows error here
sendResponse(resp,+INFORM);
Now i want the text fetch from Element INFORM is Neglect white space how can i do so? above mentioned String INFORM Show error Duplicate local variable INFORM);
e.g
text fetch by Element INFORM is "my name is satish"
but it must send response as
"mynameissatish"
You have the name INFORM used twice - and thats not possible!
String sourceUrlString = "http://some url";
Source source = new Source(new URL(sourceUrlString));
Element INFORM = source.getElementById("main").getAllElementsByClass("game").get(i-1);
String response = INFORM.replaceAll("\\s",""); // ! Use another name here !
sendResponse(resp, respone); // or use '+' - not shure if 1 or 2 args

Categories

Resources