本文整理汇总了Java中com.google.gdata.data.spreadsheet.WorksheetEntry类的典型用法代码示例。如果您正苦于以下问题:Java WorksheetEntry类的具体用法?Java WorksheetEntry怎么用?Java WorksheetEntry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WorksheetEntry类属于com.google.gdata.data.spreadsheet包,在下文中一共展示了WorksheetEntry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLatestWorksheetId
import com.google.gdata.data.spreadsheet.WorksheetEntry; //导入依赖的package包/类
private String getLatestWorksheetId(SpreadsheetEntry spreadsheet) throws Throwable
{
String worksheetId = null;
List<WorksheetEntry> worksheets = spreadsheet.getWorksheets();
Date reportCurrentDate = new Date(Long.MIN_VALUE);
for (WorksheetEntry worksheet : worksheets) {
String title = worksheet.getTitle().getPlainText();
if(title.equals("instructions") || title.equals("Sheet1") || title.startsWith("diff_") || title.startsWith("ignore_")) continue;
Date date = dateUtil.getDateFromString(title);
if (date.after(reportCurrentDate)){
reportCurrentDate = date;
worksheetId = title;
}
}
return worksheetId;
}
示例2: updateWorksheetWithAllItems
import com.google.gdata.data.spreadsheet.WorksheetEntry; //导入依赖的package包/类
private void updateWorksheetWithAllItems(WorksheetEntry worksheet, String[] header, List<ReportItem> reportItems, int numberOfRows, int numberOfColumns, String reportSpreadsheetName)
throws BatchInterruptedException, MalformedURLException, IOException, ServiceException
{
URL cellFeedUrl = worksheet.getCellFeedUrl();
CellFeed cellFeed = spreadsheetService.getFeed(cellFeedUrl, CellFeed.class);
Map<String, CellEntry> cellEntries = prepareBatchByQueringWorksheet(cellFeedUrl, numberOfRows, numberOfColumns);
int startingRow = 1;
int rowsInBatch = ((Double) Math.ceil((double)numberOfRows / Properties.googleSheetsBatchUploadSizeSplitFactor.get())).intValue();
int endingRow = rowsInBatch;
for (int i = 0; i < Properties.googleSheetsBatchUploadSizeSplitFactor.get(); i++) {
CellFeed batchRequest = createBatchRequest(header, reportItems, startingRow, endingRow, numberOfColumns, cellEntries);
Link batchLink = cellFeed.getLink(Link.Rel.FEED_BATCH, Link.Type.ATOM);
CellFeed batchResponse = spreadsheetService.batch(new URL(batchLink.getHref()), batchRequest);
boolean isSuccess = checkResults(batchResponse);
logger.info((isSuccess ? "Batch operations successful: " : "Batch operations failed: ") + reportSpreadsheetName + " " + worksheet.getTitle().getPlainText() + " starting row: " + startingRow +", through row: " + endingRow);
startingRow = startingRow + rowsInBatch;
endingRow = Math.min(numberOfRows, endingRow + rowsInBatch);
}
}
示例3: getEmptyClinicalVariants
import com.google.gdata.data.spreadsheet.WorksheetEntry; //导入依赖的package包/类
private static void getEmptyClinicalVariants(Gene gene, SpreadsheetService service, WorksheetEntry entry) throws IOException, ServiceException {
if (gene != null && service != null && entry != null) {
URL feedUrl = entry.getListFeedUrl();
Set<ClinicalVariant> variants = MainUtils.getClinicalVariants(gene);
for (ClinicalVariant variant : variants) {
if (variant.getOncoTreeType() == null || StringUtils.isNullOrEmpty(variant.getLevel())
|| (variant.getDrugAbstracts().isEmpty() && variant.getDrugPmids().isEmpty())
|| variant.getDrug().isEmpty()) {
ListEntry row = new ListEntry();
setValue(row, "Gene", gene.getHugoSymbol());
setValue(row, "Alteration", variant.getVariant().getAlteration());
setValue(row, "CancerType", getCancerType(variant.getOncoTreeType()));
setValue(row, "Level", variant.getLevel());
setValue(row, "Drug", org.apache.commons.lang3.StringUtils.join(variant.getDrug(), ", "));
setValue(row, "Pmids", org.apache.commons.lang3.StringUtils.join(variant.getDrugPmids(), ", "));
setValue(row, "Abstracts", org.apache.commons.lang3.StringUtils.join(variant.getDrugAbstracts(), ", "));
service.insert(feedUrl, row);
}
}
}
}
示例4: getEmptyBiologicalVariants
import com.google.gdata.data.spreadsheet.WorksheetEntry; //导入依赖的package包/类
private static void getEmptyBiologicalVariants(Gene gene, SpreadsheetService service, WorksheetEntry entry) throws IOException, ServiceException {
if (gene != null && service != null && entry != null) {
URL feedUrl = entry.getListFeedUrl();
Set<BiologicalVariant> variants = MainUtils.getBiologicalVariants(gene);
for (BiologicalVariant variant : variants) {
if (variant.getOncogenic() == null || variant.getMutationEffect() == null
|| (variant.getMutationEffectPmids().isEmpty() && variant.getMutationEffectAbstracts().isEmpty())) {
ListEntry row = new ListEntry();
setValue(row, "Gene", gene.getHugoSymbol());
setValue(row, "Alteration", variant.getVariant().getAlteration());
setValue(row, "Oncogenicity", variant.getOncogenic());
setValue(row, "MutationEffect", variant.getMutationEffect());
setValue(row, "PMIDs", org.apache.commons.lang3.StringUtils.join(variant.getMutationEffectPmids(), ", "));
Set<ArticleAbstract> articleAbstracts = variant.getMutationEffectAbstracts();
Set<String> abstracts = new HashSet<>();
for (ArticleAbstract articleAbstract : articleAbstracts) {
abstracts.add(articleAbstract.getAbstractContent());
}
setValue(row, "Abstracts", org.apache.commons.lang3.StringUtils.join(abstracts, ", "));
service.insert(feedUrl, row);
}
}
}
}
示例5: printTumorTypeSummary
import com.google.gdata.data.spreadsheet.WorksheetEntry; //导入依赖的package包/类
private static void printTumorTypeSummary(Set<Evidence> evidences, SpreadsheetService service, WorksheetEntry entry) throws IOException, ServiceException {
URL feedUrl = entry.getListFeedUrl();
if (evidences != null && service != null && entry != null) {
for (Evidence evidence : evidences) {
ListEntry row = new ListEntry();
setValue(row, "Gene", evidence.getGene().getHugoSymbol());
List<String> alterationNames = getAlterationNameByEvidence(evidence);
setValue(row, "Variants", MainUtils.listToString(alterationNames, ", "));
setValue(row, "CancerType", getCancerType(evidence.getOncoTreeType()));
setValue(row, "Summary", evidence.getDescription());
service.insert(feedUrl, row);
}
}
}
示例6: updateWorksheet
import com.google.gdata.data.spreadsheet.WorksheetEntry; //导入依赖的package包/类
/**
* Updates the worksheet specified by the oldTitle parameter, with the given
* title and sizes. Note that worksheet titles are not unique, so this method
* just updates the first worksheet it finds. Hey, it's just sample code - no
* refunds!
*
* @param oldTitle a String specifying the worksheet to update.
* @param newTitle a String containing the new name for the worksheet.
* @param rowCount the number of rows the new worksheet should have.
* @param colCount the number of columns the new worksheet should have.
*
* @throws ServiceException when the request causes an error in the Google
* Spreadsheets service.
* @throws IOException when an error occurs in communication with the Google
* Spreadsheets service.
*/
private void updateWorksheet(String oldTitle, String newTitle, int rowCount,
int colCount) throws IOException, ServiceException {
WorksheetFeed worksheetFeed = service.getFeed(worksheetFeedUrl,
WorksheetFeed.class);
for (WorksheetEntry worksheet : worksheetFeed.getEntries()) {
String currTitle = worksheet.getTitle().getPlainText();
if (currTitle.equals(oldTitle)) {
worksheet.setTitle(new PlainTextConstruct(newTitle));
worksheet.setRowCount(rowCount);
worksheet.setColCount(colCount);
worksheet.update();
System.out.println("Worksheet updated.");
return;
}
}
// If it got this far, the worksheet wasn't found.
System.out.println("Worksheet not found: " + oldTitle);
}
示例7: deleteWorksheet
import com.google.gdata.data.spreadsheet.WorksheetEntry; //导入依赖的package包/类
/**
* Deletes the worksheet specified by the title parameter. Note that worksheet
* titles are not unique, so this method just updates the first worksheet it
* finds.
*
* @param title a String containing the name of the worksheet to delete.
*
* @throws ServiceException when the request causes an error in the Google
* Spreadsheets service.
* @throws IOException when an error occurs in communication with the Google
* Spreadsheets service.
*/
private void deleteWorksheet(String title) throws IOException,
ServiceException {
WorksheetFeed worksheetFeed = service.getFeed(worksheetFeedUrl,
WorksheetFeed.class);
for (WorksheetEntry worksheet : worksheetFeed.getEntries()) {
String currTitle = worksheet.getTitle().getPlainText();
if (currTitle.equals(title)) {
worksheet.delete();
System.out.println("Worksheet deleted.");
return;
}
}
// If it got this far, the worksheet wasn't found.
System.out.println("Worksheet not found: " + title);
}
示例8: loadSheet
import com.google.gdata.data.spreadsheet.WorksheetEntry; //导入依赖的package包/类
/**
* Uses the user's credentials to get a list of spreadsheets. Then asks the
* user which spreadsheet to load. If the selected spreadsheet has multiple
* worksheets then the user will also be prompted to select what sheet to use.
*
* @param reader to read input from the keyboard
* @throws ServiceException when the request causes an error in the Google
* Spreadsheets service.
* @throws IOException when an error occurs in communication with the Google
* Spreadsheets service.
*
*/
public void loadSheet(BufferedReader reader) throws IOException,
ServiceException {
// Get the spreadsheet to load
SpreadsheetFeed feed = service.getFeed(factory.getSpreadsheetsFeedUrl(),
SpreadsheetFeed.class);
List spreadsheets = feed.getEntries();
int spreadsheetIndex = getIndexFromUser(reader, spreadsheets,
"spreadsheet");
SpreadsheetEntry spreadsheet = feed.getEntries().get(spreadsheetIndex);
// Get the worksheet to load
if (spreadsheet.getWorksheets().size() == 1) {
cellFeedUrl = spreadsheet.getWorksheets().get(0).getCellFeedUrl();
} else {
List worksheets = spreadsheet.getWorksheets();
int worksheetIndex = getIndexFromUser(reader, worksheets, "worksheet");
WorksheetEntry worksheet = (WorksheetEntry) worksheets
.get(worksheetIndex);
cellFeedUrl = worksheet.getCellFeedUrl();
}
System.out.println("Sheet loaded.");
}
示例9: loadSheet
import com.google.gdata.data.spreadsheet.WorksheetEntry; //导入依赖的package包/类
/**
* Uses the user's creadentials to get a list of spreadsheets. Then asks the
* user which spreadsheet to load. If the selected spreadsheet has multiple
* worksheets then the user will also be prompted to select what sheet to use.
*
* @param reader to read input from the keyboard
* @throws ServiceException when the request causes an error in the Google
* Spreadsheets service.
* @throws IOException when an error occurs in communication with the Google
* Spreadsheets service.
*
*/
public void loadSheet(BufferedReader reader) throws IOException,
ServiceException {
// Get the spreadsheet to load
SpreadsheetFeed feed = service.getFeed(factory.getSpreadsheetsFeedUrl(),
SpreadsheetFeed.class);
List spreadsheets = feed.getEntries();
int spreadsheetIndex = getIndexFromUser(reader, spreadsheets,
"spreadsheet");
SpreadsheetEntry spreadsheet = (SpreadsheetEntry) spreadsheets
.get(spreadsheetIndex);
// Get the worksheet to load
if (spreadsheet.getWorksheets().size() == 1) {
listFeedUrl = spreadsheet.getWorksheets().get(0).getListFeedUrl();
} else {
List worksheets = spreadsheet.getWorksheets();
int worksheetIndex = getIndexFromUser(reader, worksheets, "worksheet");
WorksheetEntry worksheet = (WorksheetEntry) worksheets
.get(worksheetIndex);
listFeedUrl = worksheet.getListFeedUrl();
}
System.out.println("Sheet loaded.");
}
示例10: getColumnHeaders
import com.google.gdata.data.spreadsheet.WorksheetEntry; //导入依赖的package包/类
/**
* Retrieves the columns headers from the cell feed of the worksheet
* entry.
*
* @param worksheet worksheet entry containing the cell feed in question
* @return a list of column headers
* @throws Exception if error in retrieving the spreadsheet information
*/
public List<String> getColumnHeaders(WorksheetEntry worksheet)
throws Exception {
List<String> headers = new ArrayList<String>();
// Get the appropriate URL for a cell feed
URL cellFeedUrl = worksheet.getCellFeedUrl();
// Create a query for the top row of cells only (1-based)
CellQuery cellQuery = new CellQuery(cellFeedUrl);
cellQuery.setMaximumRow(1);
// Get the cell feed matching the query
CellFeed topRowCellFeed = service.query(cellQuery, CellFeed.class);
// Get the cell entries fromt he feed
List<CellEntry> cellEntries = topRowCellFeed.getEntries();
for (CellEntry entry : cellEntries) {
// Get the cell element from the entry
Cell cell = entry.getCell();
headers.add(cell.getValue());
}
return headers;
}
示例11: getWorksheet
import com.google.gdata.data.spreadsheet.WorksheetEntry; //导入依赖的package包/类
/**
* Get the WorksheetEntry for the worksheet in the spreadsheet with the
* specified name.
*
* @param spreadsheet the name of the spreadsheet
* @param worksheet the name of the worksheet in the spreadsheet
* @return worksheet with the specified name in the spreadsheet with the
* specified name
* @throws Exception if error is encountered, such as no spreadsheets with the
* name, or no worksheet wiht the name in the spreadsheet
*/
public WorksheetEntry getWorksheet(String spreadsheet, String worksheet)
throws Exception {
SpreadsheetEntry spreadsheetEntry = getSpreadsheet(spreadsheet);
WorksheetQuery worksheetQuery
= new WorksheetQuery(spreadsheetEntry.getWorksheetFeedUrl());
worksheetQuery.setTitleQuery(worksheet);
WorksheetFeed worksheetFeed = service.query(worksheetQuery,
WorksheetFeed.class);
List<WorksheetEntry> worksheets = worksheetFeed.getEntries();
if (worksheets.isEmpty()) {
throw new Exception("No worksheets with that name in spreadhsheet "
+ spreadsheetEntry.getTitle().getPlainText());
}
return worksheets.get(0);
}
示例12: getWsList
import com.google.gdata.data.spreadsheet.WorksheetEntry; //导入依赖的package包/类
/**
* Retrieves a list of Worksheets for the specified
* spreadsheet
*
* @param wsFeedUrl The URL for the feed containing the list of worksheets
* @return A <code>List</code> of <code>HashMap</code> meta data about each
* worksheet
* @throws EPAuthenticationException
*/
public List<HashMap> getWsList(String wsFeedUrl)
throws EPAuthenticationException {
List<HashMap> returnList = new LinkedList<HashMap>();
List<WorksheetEntry> wsList = getWsListHelper(wsFeedUrl);
for (WorksheetEntry wsEntry : wsList) {
HashMap<String, String> hm = new HashMap<String, String>();
hm.put("title", wsEntry.getTitle().getPlainText());
try {
hm.put("cellFeed", FastURLEncoder.encode(
wsEntry.getCellFeedUrl().toString(),
"UTF-8"));
} catch (UnsupportedEncodingException e) {
System.err.println("Encoding error: " + e.getMessage());
}
returnList.add(hm);
}
return returnList;
}
示例13: getWsListHelper
import com.google.gdata.data.spreadsheet.WorksheetEntry; //导入依赖的package包/类
/**
* Retrieves a <code>List</code> of <code>WorksheetEntry</code> instances
* available from the list of Worksheets in the specified feed
*
* @param wsFeedUrl The feed of worksheets
* @throws EPAuthenticationException
* @return List of worksheets in the specified feed
*/
private List<WorksheetEntry> getWsListHelper(String wsFeedUrl)
throws EPAuthenticationException {
List<WorksheetEntry> returnList = null;
try {
SpreadsheetService ssService = getSsService();
WorksheetFeed wsFeed = ssService.getFeed(
new URL(wsFeedUrl),
WorksheetFeed.class);
returnList = wsFeed.getEntries();
} catch (com.google.gdata.util.AuthenticationException authEx) {
throw new EPAuthenticationException(
"WS list read access not available");
} catch (com.google.gdata.util.ServiceException svcex) {
System.err.println("ServiceException while retrieving " +
"available worksheets: " + svcex.getMessage());
returnList = null;
} catch (java.io.IOException ioex) {
System.err.println("IOException while retrieving " +
"available worksheets: " + ioex.getMessage());
returnList = null;
}
return returnList;
}
示例14: toRange
import com.google.gdata.data.spreadsheet.WorksheetEntry; //导入依赖的package包/类
public String toRange(WorksheetEntry worksheet)
{
StringBuilder builder = new StringBuilder();
Range real = this.clone();
real.realistic(worksheet);
builder.append(real.from.getColRef());
builder.append(real.from.getRow());
builder.append(":");
builder.append(real.to.getColRef());
builder.append(real.to.getRow());
return builder.toString();
}
示例15: realistic
import com.google.gdata.data.spreadsheet.WorksheetEntry; //导入依赖的package包/类
public void realistic(WorksheetEntry worksheet)
{
if (from.getCol() == Cell.BOUNDARY)
{
from.setCol(1);
}
if (from.getRow() == Cell.BOUNDARY)
{
from.setRow(1);
}
int colCount = worksheet.getColCount();
if (to.getCol() == Cell.BOUNDARY || to.getCol() > colCount)
{
to.setCol(colCount);
}
int rowCount = worksheet.getRowCount();
if (to.getRow() == Cell.BOUNDARY || to.getRow() > rowCount)
{
to.setRow(rowCount);
}
}