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"> الأجسام الأعمال -- لينكس -- الإصدار الحادي عشر 2 -- حياتك الإصدار 2

Business Objects XI Java SDK Example, Part 3 حادي عشر الأجسام الأعمال جافا SDK مثال ، الجزء 3

Continued from Business Objects XI Java SDK Example, Part 2 وواصلت من الأعمال الأجسام جافا SDK مثال الحادي عشر ، الجزء 2

Using the Business Objects example applications is a good starting point for creating a first Java SDK application. استخدام تطبيقات الأعمال الأجسام مثال هو نقطة انطلاق جيدة لإنشاء أول تطبيق جافا SDK.

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. العينة طلبات تقديم بعض المهام الأساسية ، وطريقة سهلة لتبدأ مع SDK هو استخدام واحد من الأمثلة ، وتقليم بها الشفرة التي لا تحتاج.

For our application I pieced together several of the jsp's and combined them into 2 final jsps. لطلبنا الأول بتجميع عدة من التخطيط الاستراتيجي المشترك والجمع بين 2 الى النهائي 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). لذلك ، مشيت تدفق من خلال التخطيط الاستراتيجي المشترك ، وأشار إلى أمثلة من التبعية ، ومجتمعة في نهاية المطاف الى لملفات (التخطيط الاستراتيجي المشترك).

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). حتى في هذا المثال ، هناك 's2 التخطيط الاستراتيجي المشترك التي تعبأ في جذور مستوى التطبيق الويب (loginforward.jsp البيانات وgetter.jsp). The contents are listed below: محتويات مدرجة أدناه :

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 البيانات 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 انتشار كلمة

del.icio.us Digg Furl Reddit del.icio.us Digg لف Reddit

Permalink Print 1 Comment Permalink طباعة التعليق 1

Business Objects XI SDK Example, Part 2 الأعمال SDK مثال الكائنات الحادي عشر ، الجزء 2

Continued from Business Objects XI SDK Example, part 1 وواصلت من الأعمال SDK مثال الكائنات الحادي عشر ، الجزء 1

In this post, we'll go over how we can use a python script to process BO XI Java SDK CSV output. في هذا المنصب ، ونحن نذهب الى ما يزيد على الطريقة التي يمكننا استخدام بيثون السيناريو الفرعي لعملية الحادي عشر جافا SDK CSV الانتاج.

The python script makes an http request to the web app and receives the contents. الثعبان ويجعل النص المتشعب الطلب الى الشبكة العالمية ، وتتلقى الوكالة مضمون.

The configuration file stores information to email a report. فإن ملفات مخازن المعلومات إلى البريد الإلكتروني تقرير. It contains the following information: وهو يحتوي على المعلومات التالية :


#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. محتويات للملف يجب أن لا تحتاج إلى شرح. It allows for the option of removing the header report from the dat وهو يتيح خيار رفع رأس تقريرا من دات

The "#" is the python comment symbol. "#" الثعبان رمز التعليق.

Python is case sensitive. بيثون حساس لحالة الأحرف. Be aware of this when creating configuration files. علم هذا عند إنشاء ملفات التهيئة.

The above code is read inline from the python script report-mailer.py (it is executable python code). أعلاه رمز المحول من قراءة السيناريو الثعبان وبين التقرير mailer.py (بيثون انها رمز للتنفيذ). The config files sets the appropriate values that are needed by report-mailer.py. فإن ملفات يحدد القيم المناسبة التي يحتاج إليها التقرير بين mailer.py.

Here's the contents of the python script: وإليك محتويات الثعبان والكتابة :

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 واستمر العمل SDK مثال الكائنات الحادي عشر ، الجزء 3

Spread the word انتشار كلمة

del.icio.us Digg Furl Reddit del.icio.us Digg لف Reddit

Permalink Print 2 Comments Permalink طباعة 2 التعليقات

Business Objects XI SDK Example, Part 1 الأعمال SDK مثال الكائنات الحادي عشر ، الجزء 1

The following example walks through a simple use of the Java SDK for XI. المثال التالي من خلال المشي البسيطة باستخدام جافا SDK لالحادي عشر. 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. ويفسر ذلك في خطوة بخطوة نحو كيفية الأعمال الأجسام SDK يمكن استخدامها جنبا إلى جنب مع بعض تكنولوجيات متكاملة -- بيثون السيناريو.

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. لتوضيح استخدام SDK سنبني فائدة السيناريو أن محتويات رسائل البريد الإلكتروني على الإنترنت الاستخبارات باعتبارها مصدر البيانات csv أو تبويبة تخوم الانتاج.

Why base the output on the BO data source? لماذا قاعدة ناتج عن مصدر البيانات الفرعي؟

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. بسبب طبيعة التقارير التي لحقوق قراءة الوثائق ، ومختلف عناصر واردة في التقرير من شأنه أن يكون غير مرغوب فيه بالنسبة للنظام لنظام الاتصالات. For example, reports typically have logo files, report dates, etc. When converting a report to csv these "human intended" elements can cause problems. على سبيل المثال ، عادة ما يكون شعار صورة ، تقرير التواريخ ، وغير ذلك وعند تحويل تقرير إلى csv هذه "حقوق يقصد" عناصر يمكن ان تسبب مشاكل.

We want clean, tabular output. نريد نظيفة ، جداول الانتاج.

A quick way of learning a new API is to take supplied example code and modify. طريقة سريعة للتعلم جديدة API هو اتخاذ الموردة وعلى سبيل المثال قانون تعديل.

So for this example, we will take the examples included with the Buiness Objects SDK as a starting point. حتى في هذا المثال ، سنأخذ الأمثلة المدرجة مع Buiness الكائنات SDK كنقطة انطلاق.

The functionality will be exposed as a call to a java web application (WAR), and will thus be easily deployable. وظيفة وسوف تعرض على أنها دعوة إلى تطبيق جافا ويب (حرب) ، وبذلك يكون من السهل للنشر.

The primary components of the example this little system are: والمكونات الأساسية للنظام على سبيل المثال تذكر هذه هي :

1. Web application (.war file) - contains SDK code تطبيق ويب). ملف الحرب) -- يتضمن قانون SDK

2. Python script (report-mailer.py) - talks to the web app بيثون السيناريو (تقرير - mailer.py) -- محادثات التطبيق على الويب

3. Configuration file - text file that stores configuration information, one file per report emailed ملفات -- نص ملف التكوين مخازن المعلومات ، وملف واحد لكل التقرير بالبريد الالكتروني

This example is intended for a non-packaged report with a single data source (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. وتستند الوثيقة تهيئتها للهوية (docIdentifier في ملف) ، وسوف تسحب البيانات من مصدر آخر ، والمثال على محتويات البريد الالكتروني على النحو المطلوب في ملفات.

With a little modification of the python script, we could supply output in a number of different formats. مع قليل من التعديل من الثعبان والكتابة ، يمكننا تزويد الانتاج في عدد من الأشكال المختلفة. We could write to the local file system in an ftp accessible directory (available for "pull" by other systems). نستطيع الكتابة إلى نظام الملفات المحلية في متناول دليل بروتوكول نقل الملفات (المتاحة لل"الانسحاب" من قبل النظم الأخرى). We could "push" the data to another server via FTP, SFTP, SCP, etc. يمكننا أن "الدفع" لآخر البيانات عبر خادم بروتوكول نقل الملفات ، SFTP ، جنة الخصخصة ، الخ.

The war is deployed into a java application server (eg Tomcat). الحرب المنتشرة في تطبيق خادم جافا (مثل القط). This can be the same server or a different one than the one running BO. هذا يمكن أن يكون نفس خادم واحد أو آخر من واحد على التوالي بو.

The example code supplied by Busness Objects is packaged with jars such that they can run standalone (from a BOXI server). على سبيل المثال قانون العمل المقدمة من الكائنات هو تعبئتها مع الجرار بحيث يمكن تشغيلها بذاتها (من BOXI الخادم).

Continued in Business Objects XI SDK Example , Part 2 واستمر في العمل SDK مثال الكائنات الحادي عشر ، الجزء 2

Spread the word انتشار كلمة

del.icio.us Digg Furl Reddit del.icio.us Digg لف Reddit

Permalink Print 1 Comment Permalink طباعة التعليق 1