English flagItalian flagGerman flagSpanish flagFrench flagPortuguese flagRussian flag
IC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> Business Objects - Linux - XI Release 2 - Your Life Release 2

Business Objects XI Java SDK Example, Part 3 Business Objects XI Java SDK Beispiel, Teil 3

Continued from Business Objects XI Java SDK Example, Part 2 Fortsetzung von Business Objects XI Java SDK Beispiel, Teil 2

Using the Business Objects example applications is a good starting point for creating a first Java SDK application. Mit Hilfe der Business Objects-Anwendungen Beispiel ist ein guter Ausgangspunkt für die Erstellung einer ersten Java-SDK-Anwendung.

The sample applications provide some basic tasks, and an easy way to get started with the SDK is to use one of the examples, and trim out the code that you don't need. Die Probe-Anwendungen bieten einige grundlegende Aufgaben, und eine einfache Möglichkeit, sich mit dem SDK ist die Verwendung eines der Beispiele, und schneiden Sie den Code ein, den Sie nicht brauchen.

For our application I pieced together several of the jsp's and combined them into 2 final jsps. Für unsere Anwendung Pieced ich zusammen einige der JSP-und kombiniert sie in 2 endgültig JSPs. To do this, I walked through the flow of the jsp examples and noted the dependencies, and ultimately combined them into to files (jsp's). Um dies zu tun, ich ging durch die Strömung des jsp Beispiele und stellte fest, die Abhängigkeiten und letztlich kombiniert sie in die Dateien (JSP's).

So in this example, there are 2 jsp's that are packaged at the root level of the web app (loginforward.jsp and data-getter.jsp). Also in diesem Beispiel gibt es 2 jsp's, die verpackt in der Root-Ebene des Web App (loginforward.jsp und Daten-getter.jsp). The contents are listed below: Die Inhalte sind im Folgenden aufgeführt:

loginforward.jsp



<!--
********************************************************************************

Adapted from WebIntelligence RE SDK JSP Tutorials 115.000.00000

Tutorials are Copyright (c) 2002-2005 Business Objects SA

********************************************************************************
-->

<%@ page language="java" errorPage="err_page.jsp"%>
<%@ page contentType="text/html; charset=utf-8" %>
<%@ page import="com.businessobjects.rebean.wi.ReportEngine" %>
<%@ page import="com.crystaldecisions.sdk.exception.SDKException" %>
<%@ page import="com.crystaldecisions.sdk.exception.SDKServerException" %>
<%@ page import="com.crystaldecisions.sdk.framework.CrystalEnterprise" %>
<%@ page import="com.crystaldecisions.sdk.framework.IEnterpriseSession" %>
<%@ page import="com.crystaldecisions.sdk.framework.ISessionMgr" %>
<%@ page import="com.crystaldecisions.sdk.occa.infostore.IInfoStore" %>
<%@ page import="com.crystaldecisions.sdk.occa.security.IUserInfo" %>
<%@ page import="com.crystaldecisions.sdk.occa.infostore.CeSecurityID" %>
<%@ page import="com.crystaldecisions.sdk.occa.infostore.IInfoObjects" %>
<%@ page import="com.crystaldecisions.sdk.occa.infostore.IInfoObject" %>
<%@ page import="com.crystaldecisions.sdk.plugin.desktop.server.IServer"%>
<%@ page import="com.crystaldecisions.sdk.plugin.CeKind" %>
<%@ page import="com.crystaldecisions.sdk.occa.enadmin.*" %>
<%@ page import="com.businessobjects.sdk.plugin.desktop.webintelligence.CeWebIntelligenceRightID" %>
<%@ page import="java.io.IOException" %>
<%@ page import="java.util.Hashtable" %>

<%@ include file="rights_method.jsp" %>

<%
request.setCharacterEncoding("utf-8");
String CMS = request.getParameter("CMS");
if (CMS.equals("localhost"))
response.sendRedirect("loginForm.jsp?strError=localhost");
String userName= request.getParameter("User");
String userPass = request.getParameter("Password");
String auth = request.getParameter("auth");

// doc identifier
request.setAttribute("docIdentifier",request.getParameter("docIdentifier"));

IEnterpriseSession enterpriseSession= null;
IInfoStore iStore = null;
IUserInfo userInfo = null;

try
{
//Open the session
final ISessionMgr sessionMgr = CrystalEnterprise.getSessionMgr();
enterpriseSession = sessionMgr.logon(userName, userPass, CMS, auth);

}
catch(SDKServerException ex)
{
%>
<jsp:forward page="error_wrongLogin.html" />
<%

}

catch(SDKException.SecurityError exSec)
{
%>
<jsp:forward page="error_authentication.html" />
<%
}

catch(SDKException.OCAFramework exOCA )
{
%>
<jsp:forward page="error_serverName.html" />
<%
}

catch(Exception e)
{

%>
<jsp:forward page="error_login.html" />
<%
}

try{

userInfo = enterpriseSession.getUserInfo();
iStore = (IInfoStore)enterpriseSession.getService("InfoStore");

ReportEngines reportEngines = null;
if (enterpriseSession != null)
{
reportEngines = (ReportEngines)request.getAttribute("ReportEngines");
if (reportEngines == null)
{
//Create a new ReportEngines
reportEngines = (ReportEngines)enterpriseSession.getService("ReportEngines");

request.setAttribute("ReportEngines", reportEngines);
}
}

}
catch (Exception e)
{
%>
<jsp:forward page="error_login.html" />
<%
}


String strSampleVersion = "11.5";

//Test the version of the server
String strQuery = "Select SI_ID, SI_NAME, SI_SERVER_KIND from CI_SYSTEMOBJECTS where SI_KIND ='" CeKind.SERVER "'" " AND SI_SERVER_KIND= 'aps'";
IInfoObjects iServers = (IInfoObjects)iStore.query(strQuery);

String strShortServerVersion ="";
if (iServers != null)
{
IServer iServer = (IServer)iServers.get(0);
IServerGeneralMetrics iServerGeneralMetrics = (IServerGeneralMetrics) iServer.getServerGeneralAdmin();
String strServerVersion = iServerGeneralMetrics.getVersion();
strShortServerVersion = strServerVersion.substring(0,4);

}//if (IServers != null)


//Test the version of the REBEAN SDK
String strSDKVersion = enterpriseSession.getClass().getPackage().getImplementationVersion();
String strShortSDKVersion = strSDKVersion.substring(0,4);


String strErrorMessage="";
if (!strShortServerVersion.equals(strShortSDKVersion))
{
strErrorMessage="Warning: SDK and backbone versions do not match </br> Please update your sdk librairies to version" strShortServerVersion;
}
else if((Float.parseFloat(strSampleVersion)) < (Float.parseFloat(strShortSDKVersion)) )
{
strErrorMessage = "Warning: application was not tested using version " strShortSDKVersion "of the sdk";
}
else if((Float.parseFloat(strSampleVersion)) > (Float.parseFloat(strShortSDKVersion)) )
{
strErrorMessage="Warning: application was developed with a more recent sdk. Execution may fail.";
}

if(!strErrorMessage.equals(""))
response.sendRedirect("error_version.jsp?message=" strErrorMessage);

request.setAttribute("EnterpriseSession", enterpriseSession);

request.setAttribute("InfoStore", iStore);

//Store user info
session.setAttribute("UserInfo",userInfo);
request.setAttribute("UserInfo",userInfo);

//Check if the password has expired
if (userInfo.getPasswordExpiry() == 0){

StringBuffer urlChgPasswd = new StringBuffer();
urlChgPasswd = urlChgPasswd.append("forceChgPassword.jsp?");
urlChgPasswd = urlChgPasswd.append("User=");
urlChgPasswd = urlChgPasswd.append(userName);
urlChgPasswd = urlChgPasswd.append("&auth=");
urlChgPasswd = urlChgPasswd.append(auth);
urlChgPasswd = urlChgPasswd.append("&CMS=");
urlChgPasswd = urlChgPasswd.append(CMS);

response.sendRedirect(urlChgPasswd.toString());
}
else
{

// Get the folder id that is root of all universes
strQuery = "SELECT SI_ID, SI_NAME, SI_PARENTID FROM CI_APPOBJECTS "
"WHERE SI_PARENTID = '" CeSecurityID.Folder.SEMANTIC_LAYERS "' AND SI_KIND = '" CeKind.FOLDER "' AND SI_NAME = 'Universes'";

IInfoObjects iInfoObjects = iStore.query(strQuery);
String strUniverseRootFolderId = "";

if (iInfoObjects != null && iInfoObjects.size() > 0)
strUniverseRootFolderId = String.valueOf(((IInfoObject) iInfoObjects.get(0)).getID());

// Store folder id that is root of all universes
session.setAttribute("UniverseRootFolderId", strUniverseRootFolderId);

// Create a Hashtable to store the rights of the user
Hashtable userRights = new Hashtable();

strQuery = "SELECT SI_ID, SI_KIND FROM CI_APPOBJECTS "
"WHERE SI_PARENTID = '" CeSecurityID.Folder.APPLICATIONS "' AND SI_KIND = '" CeKind.WEBINTELLIGENCE "'";
IInfoObjects iWebiAppObjects = iStore.query(strQuery);

if (iWebiAppObjects != null && iWebiAppObjects.size()>0)
{
IInfoObject iWebiAppObject = (IInfoObject) iWebiAppObjects.get(0);

// Check the some rights on the application object "Webintelligence" and store their value in the hashtable userRights
checkApplicationObjectRight(CeWebIntelligenceRightID.CREATEDOCUMENTS, iWebiAppObject, "CREATE_DOCUMENT", userRights);
checkApplicationObjectRight(CeWebIntelligenceRightID.DRILLMODE, iWebiAppObject, "DRILL_MODE", userRights);
checkApplicationObjectRight(CeWebIntelligenceRightID.EXTENDSCOPE, iWebiAppObject, "EXTEND_SCOPE", userRights);
}

session.setAttribute("userRights", userRights);


%><jsp:forward page="data-getter2.jsp" /><%
} // else of if (userInfo.getPasswordExpiry() == 0)
%>

data-getter.jsp Daten-getter.jsp





<!--
********************************************************************************

Adapted from WebIntelligence RE SDK JSP Tutorials 115.000.00000

Tutorials are Copyright (c) 2002-2005 Business Objects SA

********************************************************************************
-->


<%@ page language="java" errorPage="../err_page.jsp"%>
<%@ page import="com.businessobjects.rebean.wi.*,java.io.*" %>
<%@ page import="java.util.BitSet, java.util.Enumeration, java.util.StringTokenizer, java.util.Date" %><%@ page import="java.text.ParseException, java.text.SimpleDateFormat, java.io.IOException" %><%!
// =============================================================================

// The separator between the different selected values of a list
static final String C_STR_SEPARATOR = ";";

// =============================================================================

static final int iCaseDiff = ('a' - 'A');

// =============================================================================

// The list of characters that are not encoded have been determined
// by referencing O'Reilly's "HTML: The Definitive Guide" (page 164).
static BitSet objBitSetCharactersNotToEncode;

static
{
int iCharIndex;

objBitSetCharactersNotToEncode = new BitSet(256);

for (iCharIndex = 'a'; iCharIndex <= 'z'; iCharIndex )
objBitSetCharactersNotToEncode.set(iCharIndex);

for (iCharIndex = 'A'; iCharIndex <= 'Z'; iCharIndex )
objBitSetCharactersNotToEncode.set(iCharIndex);

for (iCharIndex = '0'; iCharIndex <= '9'; iCharIndex )
objBitSetCharactersNotToEncode.set(iCharIndex);

// A space needs a special encoding: it should be transformed into a ' '
// this is done in the method URLEncodeUTF8 below
objBitSetCharactersNotToEncode.set(' ');
objBitSetCharactersNotToEncode.set('-');
objBitSetCharactersNotToEncode.set('_');
objBitSetCharactersNotToEncode.set('.');
objBitSetCharactersNotToEncode.set('*');
} // static code

// =============================================================================

// Tell if the given value is an item of the array of the selected values
public String isValuePartOfTheSelection(String strValue, String[] astrSelectedValues)
{
if (astrSelectedValues == null)
return "";

for (int iSelectedIndex = 0; iSelectedIndex < astrSelectedValues.length; iSelectedIndex )
if (strValue.equals(astrSelectedValues[iSelectedIndex]))
return " selected";

return "";
} // method isValuePartOfTheSelection

// =============================================================================

// Concatenate the given value to the list of the selected values
public void addToList(String strItem, StringBuffer objStringBufferItemList)
{
if (objStringBufferItemList.length() != 0)
objStringBufferItemList.append(C_STR_SEPARATOR);

objStringBufferItemList.append(strItem);
} // method addToList

// =============================================================================

// Return a string listing the different values of the given array
// Known limitation: value should not include C_STR_SEPARATOR
public String convertArrayToString(String[] astr)
{
if ((astr == null) || (astr.length == 0))
return "";

StringBuffer objStringBuffer = new StringBuffer("");

for (int iIndex = 0; iIndex < astr.length; iIndex )
{
if (iIndex != 0)
objStringBuffer.append(C_STR_SEPARATOR);

objStringBuffer.append(astr[iIndex]);
} // for (iIndex)

return objStringBuffer.toString();
} // method convertArrayToString

// =============================================================================

// Split delimited string of values into an array
public String[] splitValues(String strValueList)
{
if (strValueList == null)
return null;

StringTokenizer strTokenizer = new StringTokenizer(strValueList, C_STR_SEPARATOR);
int iValueCount = strTokenizer.countTokens();
String[] astrValues = new String[iValueCount];

for (int iValueIndex = 0; iValueIndex < iValueCount; iValueIndex )
astrValues[iValueIndex] = strTokenizer.nextToken();

return astrValues;
} // method splitValues

// =============================================================================

// Return a non null value for the given string
public String getNonNullValue(String strParameterValue, String strDefaultValue)
{
if (strParameterValue == null)
strParameterValue = strDefaultValue;
else if (strParameterValue.equals("null"))
strParameterValue = strDefaultValue;

return strParameterValue;
} // method getNonNullValue

// =============================================================================

// Return a non null value for the given string
// (considering that default value is an empty string)
public String getNonNullValue(String strParameterValue)
{
return getNonNullValue(strParameterValue, "");
} // method getNonNullValue

// =============================================================================

// Return an array of non null values for the given string array
public String[] getNonNullValues(String[] astrParameterValues)
{
if (astrParameterValues == null)
astrParameterValues = new String[0];

return astrParameterValues;
} // method getNonNullValues

String URLEncodeUTF8(String strToEncode)
{
try
{
byte[] abyUTF8 = strToEncode.getBytes("UTF-8");
// The maximal size should be string length * 3 (%XX instead of a single char)
StringBuffer objStringBuffer = new StringBuffer(abyUTF8.length * 3);

for (int iByteIndex = 0; iByteIndex < abyUTF8.length; iByteIndex )
{
int iChar = (int) abyUTF8[iByteIndex];

if (iChar < 0)
iChar = 256; // get an unsigned byte value in [0,256[

// If the character doesn't need encoding,
if (objBitSetCharactersNotToEncode.get(iChar))
{
if (iChar == 0x20)
// ' ' replaced by ' '
iChar = 0x2B;

objStringBuffer.append((char) iChar);
}
// Else, the character needs encoding,
else
{
// It should be escaped by %XX (XX is the hex value of the byte)
objStringBuffer.append('%');

char cChar = Character.forDigit((abyUTF8[iByteIndex] >> 4) & 0xF, 16);

if (Character.isLetter(cChar))
// convert the character to upper case (ex: 'a' -> 'A') as part of the hex value
cChar -= iCaseDiff;

objStringBuffer.append(cChar);

cChar = Character.forDigit(abyUTF8[iByteIndex] & 0xF, 16);

if (Character.isLetter(cChar))
// convert the character to upper case (ex: 'a' -> 'A') as part of the hex value
cChar -= iCaseDiff;

objStringBuffer.append(cChar);
} // else of if (objBitSetCharactersNotToEncode.get(iChar))
} // for (iByteIndex)

return objStringBuffer.toString();
}
catch (java.io.UnsupportedEncodingException objUnsupportedEncodingException)
{
System.out.println("UnsupportedEncodingException on " strToEncode);
return (java.net.URLEncoder.encode(strToEncode));
} // catch (java.io.UnsupportedEncodingException)
} // method URLEncodeUTF8

// ============================================================================= end useful methods
%>


<%@ page import="com.crystaldecisions.sdk.framework.IEnterpriseSession" %>
<%

// The session attribute, used for displaying user messages
final String C_STR_INFORMATION_SESSION_ATTRIBUTE = "informationMessage";

// The different values of the page parameter, used for navigating into documents
final String C_STR_PAGE_FIRST = "first";
final String C_STR_PAGE_PREVIOUS = "prev";
final String C_STR_PAGE_NEXT = "next";
final String C_STR_PAGE_LAST = "last";

// The display of the particular values of a list
final String C_STR_ALL = "*";
final String C_STR_NOTHING = "Nothing";

//Retrieve the Object Session
IEnterpriseSession enterpriseSession = (IEnterpriseSession)request.getAttribute("EnterpriseSession");

// Get the locale of the server
String strLocale = request.getLocale().getLanguage();


%>


<%@ page import="com.crystaldecisions.sdk.occa.infostore.IInfoStore" %>
<%@ page import="com.crystaldecisions.sdk.occa.security.IUserInfo" %>
<%@ page import="com.crystaldecisions.sdk.occa.infostore.IInfoObjects" %>
<%@ page import="com.crystaldecisions.sdk.occa.infostore.IInfoObject" %>
<%@ page import="com.crystaldecisions.sdk.exception.SDKException" %>
<%@ page import="com.crystaldecisions.sdk.occa.infostore.ISecurityInfo" %>
<%@ page import="java.util.Locale" %>
<%@ page import="java.io.IOException" %>

<%

ReportEngines reportEngines = (ReportEngines) request.getAttribute("ReportEngines");

IInfoStore iStore = (IInfoStore) request.getAttribute("InfoStore");

String strDocUID = (String) request.getAttribute("docIdentifier");


String strDocUIDType = "id";
String strEntry = getNonNullValue(request.getParameter("entry"));
String strDocId = null;

if (strDocUID.length() != 0)
if (strDocUIDType.equals("id"))
strDocId = strDocUID;
else
strEntry = strDocUID;


DocumentInstance document = null;

// If a storage token has been given
if (! strEntry.equals(""))
{
try{
// Retrieve the correct ReportEngine from the storage token
ReportEngine reportEngine = reportEngines.getServiceFromStorageToken(strEntry);

// Retrieve the document using its storage token
document = reportEngine.getDocumentFromStorageToken(strEntry);
}catch(Exception ex){
response.sendRedirect("../error_token.html");
}

}
// Else if a document id or a document name has been given
else if (! strDocId.equals(""))
{
//Check the SI_KIND of the Document to instanciate the correct reportEngine
String strQuery = "Select SI_KIND from CI_INFOOBJECTS where SI_ID=" strDocId;
IInfoObjects iDocObjects = iStore.query(strQuery);
IInfoObject iDocObject = null;

String strQuery2 = "Select * from CI_INFOOBJECTS where SI_ID=" strDocId;
IInfoObjects iDocObjects2 = iStore.query(strQuery2);


IInfoObject iDocObject2 = null;

try{

iDocObject = (IInfoObject) iDocObjects.get(0);

iDocObject2 = (IInfoObject) iDocObjects2.get(0);
}
catch(Exception ex)
{
response.sendRedirect("../error_documentNotFound.html");
}

String strKind = iDocObject.getKind();
com.crystaldecisions.sdk.occa.infostore.ISchedulable iDocObject3 = (com.crystaldecisions.sdk.occa.infostore.ISchedulable) iDocObject2;

IInfoObject iDocObject4 = iDocObject3.getLatestInstance();

int latestInstanceID = iDocObject4.getID();


ReportEngine reportEngine = null;


if(strKind.equalsIgnoreCase("Webi"))
{
reportEngine = reportEngines.getService(ReportEngines.ReportEngineType.WI_REPORT_ENGINE);
reportEngine.setLocale(strLocale);
}
else
{
reportEngine = reportEngines.getService(ReportEngines.ReportEngineType.FC_REPORT_ENGINE);
reportEngine.setLocale(strLocale);
}


// Open the document from its identifiers
// document = reportEngine.openDocument(Integer.parseInt(strDocId));
try{
document = reportEngine.openDocument( latestInstanceID );
}catch(Exception e9){
e9.printStackTrace();
}


} // if (! strEntry.equals(""))

// *****************************************************************************
%>


<%

// Retrieve parameters
String strDataProviderIndex = getNonNullValue(request.getParameter("dataprovider"), "0");
int iDataProvider = Integer.parseInt(strDataProviderIndex);

DataProviders dataProviders = document.getDataProviders();
int iDataProviderCount = dataProviders.getCount();


// If document is empty
if (iDataProviderCount <= 0)
{
%><%@ include file="../error_noDataProvider.html" %><%

return;
} // if (iDataProvider <= 0)

// Set dataprovider
DataProvider dataProvider = dataProviders.getItem(iDataProvider);

// *****************************************************************************
%>

<%
response.setDateHeader("expires", 0);

%>

<%


if (strEntry.equals(""))
// Get storage token
strEntry = document.getStorageToken();

out.clearBuffer();
CharacterView cvOutput;
InputStream isXML;
int available;
byte[] data;
int nbBytes;
StringBuffer sbResult = new StringBuffer();

cvOutput = dataProvider.getResultAsCSV(-1); //cih
out.print(cvOutput.getContent()); //cih

%>



<%
if (enterpriseSession != null){
enterpriseSession.logoff();
}
// *****************************************************************************
%>

Spread the word Spread the word

del.icio.us Digg Furl Reddit del.icio.us Digg Furl Reddit

Permalink Print 1 Comment Permalink Drucken 1 Kommentar

Business Objects XI SDK Example, Part 2 Business Objects XI-SDK Beispiel, Teil 2

Continued from Business Objects XI SDK Example, part 1 Fortsetzung von Business Objects XI-SDK Beispiel, Teil 1

In this post, we'll go over how we can use a python script to process BO XI Java SDK CSV output. In diesem Post, wir gehen, wie können wir ein Python-Skript zu verarbeiten BO XI Java SDK CSV ausgegeben.

The python script makes an http request to the web app and receives the contents. Die Python-Skript macht eine HTTP-Anfrage an die Web-Anwendung und den Inhalt.

The configuration file stores information to email a report. Die Konfigurations-Datei speichert Informationen zu E-Mail einen Bericht. It contains the following information: Es enthält die folgenden Informationen:


#report-mailer.py

REMOVE_HEADER_ROW = True
#REMOVE_HEADER_ROW = False

COLUMN_SEPARATOR = " "
#COLUMN_SEPARATOR = ","

to = "noreply@noreply.com,noreply2@noreply.com "
sentfrom = "noreply@noreply.com"

User = "testuser "
Password = "password"
docIdentifier = "442005"


The contents of the config file should be self-explanatory. Der Inhalt der Konfigurationsdatei sollten selbsterklärend sein. It allows for the option of removing the header report from the dat Es erlaubt die Möglichkeit der Beseitigung der Kopfzeile Bericht der DAT

The "#" is the python comment symbol. Das "#" ist die Python-Kommentar-Symbol.

Python is case sensitive. Python ist Groß-und Kleinschreibung. Be aware of this when creating configuration files. Beachten Sie bei der Erstellung dieses Konfigurations-Dateien.

The above code is read inline from the python script report-mailer.py (it is executable python code). Die oben genannten Inline-Code wird von der Python-Skript-Bericht mailer.py (es ist ausführbaren Python-Code). The config files sets the appropriate values that are needed by report-mailer.py. Die config-Dateien setzt die entsprechenden Werte, die nötig sind, durch die Bericht-mailer.py.

Here's the contents of the python script: Hier ist der Inhalt des Python-Skript:

import sys
import smtplib
from email.MIMEText import MIMEText
import urllib

REMOVE_HEADER_ROW = True

COLUMN_SEPARATOR = " "
#COLUMN_SEPARATOR = ","

CSV_EXTRACT_URL = "http://dev1:8080/dpvalues/loginforward.jsp"

auth = "secEnterprise"
CMS = "ersdev1"

to = "noreply@noreply.com"
sentfrom = "noreply@noreply.com"

config_file = sys.argv[1]


#read in config info, and overwrite defaults set above
execfile(config_file)

params = urllib.urlencode({'CMS': CMS, 'User': User, 'Password': Password, 'auth':auth, 'docIdentifier':docIdentifier })

print str(params)

f = urllib.urlopen(CSV_EXTRACT_URL, params)
raw = f.read()

rows = raw.split("\n")
if REMOVE_HEADER_ROW:
rows = rows[1:]

buf = ""
for x in rows:
cln = x.strip()
if len(cln) < 3:
continue
sp = cln[1:-1].split('";"')
buf = COLUMN_SEPARATOR.join( sp ) "\n"


msg = MIMEText(buf)

msg['Subject'] = 'csv values'
msg['From'] = sentfrom
msg['To'] = to

s = smtplib.SMTP()
s.connect()
s.sendmail(sentfrom, [to], msg.as_string())
s.close()



Continued on Business Objects XI SDK Example, part 3 Fortsetzung auf der Business Objects XI-SDK Beispiel, Teil 3

Spread the word Spread the word

del.icio.us Digg Furl Reddit del.icio.us Digg Furl Reddit

Permalink Print 2 Comments Permalink Drucken 2 Kommentare

Business Objects XI SDK Example, Part 1 Business Objects XI-SDK Beispiel, Teil 1

The following example walks through a simple use of the Java SDK for XI. Das folgende Beispiel geht durch eine einfache Nutzung des Java-SDK für die XI. It explains in a step-by-step manner how the Business Objects SDK can be used in conjunction with some complementary technologies - a python script. Er erklärt in einer Schritt-für-Schritt-Weise, wie die Business Objects SDK kann in Verbindung mit einigen ergänzenden Technologien - ein Python-Skript.

To illustrate SDK usage we will build a utility script that emails the contents of a Web Intelligence data source as a csv or tab delimited output. Um zu veranschaulichen, SDK Nutzung bauen wir eine Utility-Skript, dass E-Mails den Inhalt eines Web Intelligence-Datenquelle als csv-oder tabulatorgetrennte "ausgegeben.

Why base the output on the BO data source? Warum bei der Ausgabe auf die BO-Datenquelle?

Because of the nature of reports being intended for human readability, various elements are included in a report that would be undesirable for system to system communication. Aufgrund der Art der Berichte, die für den menschlichen Lesbarkeit, verschiedene Elemente sind in einem Bericht, wäre nicht wünschenswert für System zu System Kommunikation. For example, reports typically have logo files, report dates, etc. When converting a report to csv these "human intended" elements can cause problems. Zum Beispiel, Berichte haben in der Regel Logo-Dateien, Daten-Bericht, etc. Bei der Umwandlung eines Berichts in das CSV dieser "menschlichen, die" Elemente kann zu Problemen führen.

We want clean, tabular output. Wir wollen sauber, tabellarisch ausgegeben.

A quick way of learning a new API is to take supplied example code and modify. Eine schnelle Art und Weise des Lernens eine neue API ist die mitgelieferte Beispiel-Code und ändern.

So for this example, we will take the examples included with the Buiness Objects SDK as a starting point. Also, für dieses Beispiel, nehmen wir die Beispiele, die mit dem SDK Buiness Objekte als Ausgangspunkt.

The functionality will be exposed as a call to a java web application (WAR), and will thus be easily deployable. Die Funktionalität wird ausgesetzt, wie der Aufruf zu einer Java-Web-Anwendung (WAR), und werden somit leicht verlegefähige.

The primary components of the example this little system are: Die primären Komponenten von diesem kleinen Beispiel sind:

1. Web application (.war file) - contains SDK code Web-Anwendung (. WAR-Datei) - enthält SDK-Code

2. Python script (report-mailer.py) - talks to the web app Python-Skript (Bericht-mailer.py) - Gespräch mit dem Web-app

3. Configuration file - text file that stores configuration information, one file per report emailed Konfigurations-Datei - Text-Datei, die Informationen speichert Konfiguration, eine Datei pro Bericht per E-Mail

This example is intended for a non-packaged report with a single data source (query). Dieses Beispiel ist für eine nicht-verpackt Bericht mit einer einzigen Datenquelle (query). Based on the configured document identifier (docIdentifier in the config file), it will pull the data source from the latest instance and email the contents as requested in the configuration file. Auf der Grundlage der konfigurierten Dokument-ID (docIdentifier in der config-Datei), wird sie ziehen Sie die Datenquelle, aus der aktuellen Instanz und die E-Mail-Inhalte, wie in der Konfigurationsdatei.

With a little modification of the python script, we could supply output in a number of different formats. Mit einer kleinen Änderung der Python-Skript, wir liefern könnte Ausgabe in einer Reihe von verschiedenen Formaten. We could write to the local file system in an ftp accessible directory (available for "pull" by other systems). Wir könnten ein Schreiben an die lokale Datei in ein FTP-Verzeichnis zugänglich (für "ziehen" von anderen Systemen). We could "push" the data to another server via FTP, SFTP, SCP, etc. Wir könnten "Push"-Daten auf einen anderen Server per FTP, SFTP, SCP, etc.

The war is deployed into a java application server (eg Tomcat). Der Krieg ist zum Einsatz in einem Java-Application-Server (zB Tomcat). This can be the same server or a different one than the one running BO. Dies kann dem gleichen Server oder eine andere als die laufenden BO.

The example code supplied by Busness Objects is packaged with jars such that they can run standalone (from a BOXI server). Die Beispiel-Code von Business Objects wird mit Gläsern, so dass sie können Standalone (von BOXI Server).

Continued in Business Objects XI SDK Example , Part 2 Fortsetzung in Business Objects XI SDK Beispiel, Teil 2

Spread the word Spread the word

del.icio.us Digg Furl Reddit del.icio.us Digg Furl Reddit

Permalink Print 1 Comment Permalink Drucken 1 Kommentar