2012-10-09 12:52:35 -04:00
|
|
|
<?php
|
2010-12-02 23:34:41 +00:00
|
|
|
/**
|
|
|
|
|
* class.javaBridgePM.php
|
2012-10-09 12:52:35 -04:00
|
|
|
*
|
2011-02-01 12:49:40 +00:00
|
|
|
* @package workflow.engine.classes
|
2010-12-02 23:34:41 +00:00
|
|
|
*
|
|
|
|
|
* ProcessMaker Open Source Edition
|
2011-02-01 12:49:40 +00:00
|
|
|
* Copyright (C) 2004 - 2011 Colosa Inc.
|
2010-12-02 23:34:41 +00:00
|
|
|
*
|
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2012-10-09 12:52:35 -04:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2010-12-02 23:34:41 +00:00
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
2012-10-09 12:52:35 -04:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2010-12-02 23:34:41 +00:00
|
|
|
*
|
|
|
|
|
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
|
|
|
|
|
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
2011-02-01 12:49:40 +00:00
|
|
|
*/
|
2012-10-09 12:52:35 -04:00
|
|
|
|
2013-03-14 15:50:49 -04:00
|
|
|
if (! defined( 'JAVA_BRIDGE_PATH' )) {
|
2012-10-09 12:52:35 -04:00
|
|
|
define( 'JAVA_BRIDGE_PATH', 'JavaBridgePM' );
|
2013-03-14 15:50:49 -04:00
|
|
|
}
|
|
|
|
|
if (! defined( 'JAVA_BRIDGE_PORT' )) {
|
2012-10-09 12:52:35 -04:00
|
|
|
define( 'JAVA_BRIDGE_PORT', '8080' );
|
2013-03-14 15:50:49 -04:00
|
|
|
}
|
|
|
|
|
if (! defined( 'JAVA_BRIDGE_HOST' )) {
|
2012-10-09 12:52:35 -04:00
|
|
|
define( 'JAVA_BRIDGE_HOST', '127.0.0.1' );
|
2013-03-14 15:50:49 -04:00
|
|
|
}
|
2012-10-09 12:52:35 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @package workflow.engine.classes
|
|
|
|
|
*/
|
2017-08-11 11:10:27 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @package workflow.engine.classes
|
|
|
|
|
*/class JavaBridgePM
|
2012-10-09 12:52:35 -04:00
|
|
|
{
|
2013-03-14 15:50:49 -04:00
|
|
|
public $JavaBridgeDir = JAVA_BRIDGE_PATH;
|
|
|
|
|
public $JavaBridgePort = JAVA_BRIDGE_PORT;
|
|
|
|
|
public $JavaBridgeHost = JAVA_BRIDGE_HOST;
|
2010-12-02 23:34:41 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* checkJavaExtension
|
2012-10-09 12:52:35 -04:00
|
|
|
* check if the java extension was loaded.
|
|
|
|
|
*
|
2010-12-02 23:34:41 +00:00
|
|
|
*
|
2012-10-09 12:52:35 -04:00
|
|
|
* @return true or false
|
|
|
|
|
*/
|
2013-03-14 15:50:49 -04:00
|
|
|
public function checkJavaExtension ()
|
2010-12-02 23:34:41 +00:00
|
|
|
{
|
2012-10-09 12:52:35 -04:00
|
|
|
try {
|
|
|
|
|
if (! extension_loaded( 'java' )) {
|
|
|
|
|
if (! (@include_once ("java/Java.inc"))) {
|
|
|
|
|
$urlJavaInc = "http://$this->JavaBridgeHost:$this->JavaBridgePort/$this->JavaBridgeDir/java/Java.inc";
|
|
|
|
|
@include_once ($urlJavaInc);
|
|
|
|
|
$includedFiles = get_included_files();
|
|
|
|
|
$found = false;
|
|
|
|
|
foreach ($includedFiles as $filename) {
|
2013-03-14 15:50:49 -04:00
|
|
|
if ($urlJavaInc == $filename) {
|
2012-10-09 12:52:35 -04:00
|
|
|
$found = true;
|
2013-03-14 15:50:49 -04:00
|
|
|
}
|
2012-10-09 12:52:35 -04:00
|
|
|
}
|
|
|
|
|
if (! $found) {
|
|
|
|
|
throw new Exception( 'The PHP/Java Bridge is not defined' );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return true;
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
2012-10-09 12:52:35 -04:00
|
|
|
|
|
|
|
|
if (! function_exists( "java_get_server_name" )) {
|
|
|
|
|
throw new Exception( 'The loaded java extension is not the PHP/Java Bridge' );
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
2012-10-09 12:52:35 -04:00
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
throw new Exception( 'Error in checkJavaExtension: ' . $e->getMessage() );
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
|
|
|
|
}
|
2012-10-09 12:52:35 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* convert a php value to a java one...
|
|
|
|
|
*
|
|
|
|
|
* @param string $value
|
|
|
|
|
* @param string $className
|
|
|
|
|
* @return s boolean success
|
|
|
|
|
*/
|
2013-03-14 15:50:49 -04:00
|
|
|
public function convertValue ($value, $className)
|
2012-10-09 12:52:35 -04:00
|
|
|
{
|
|
|
|
|
// if we are a string, just use the normal conversion
|
|
|
|
|
// methods from the java extension...
|
|
|
|
|
try {
|
|
|
|
|
if ($className == 'java.lang.String') {
|
|
|
|
|
$temp = new Java( 'java.lang.String', $value );
|
|
|
|
|
return $temp;
|
2013-03-14 15:50:49 -04:00
|
|
|
} elseif ($className == 'java.lang.Boolean' || $className == 'java.lang.Integer' || $className == 'java.lang.Long' || $className == 'java.lang.Short' || $className == 'java.lang.Double' || $className == 'java.math.BigDecimal') {
|
2012-10-09 12:52:35 -04:00
|
|
|
$temp = new Java( $className, $value );
|
|
|
|
|
return $temp;
|
2013-03-14 15:50:49 -04:00
|
|
|
} elseif ($className == 'java.sql.Timestamp' || $className == 'java.sql.Time') {
|
2012-10-09 12:52:35 -04:00
|
|
|
$temp = new Java( $className );
|
|
|
|
|
$javaObject = $temp->valueOf( $value );
|
|
|
|
|
return $javaObject;
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception $err) {
|
|
|
|
|
echo ('unable to convert value, ' . $value . ' could not be converted to ' . $className);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
echo ('unable to convert value, class name ' . $className . ' not recognised');
|
|
|
|
|
return false;
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
2012-10-09 12:52:35 -04:00
|
|
|
|
2010-12-02 23:34:41 +00:00
|
|
|
/**
|
2012-10-09 12:52:35 -04:00
|
|
|
* generateJrxmlFromDynaform
|
|
|
|
|
*
|
|
|
|
|
* @param string $outDocUid
|
|
|
|
|
* @param string $dynaformUid
|
|
|
|
|
* @param object $template
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
2013-03-14 15:50:49 -04:00
|
|
|
public function generateJrxmlFromDynaform ($outDocUid, $dynaformUid, $template)
|
2012-10-09 12:52:35 -04:00
|
|
|
{
|
|
|
|
|
require_once 'classes/model/Dynaform.php';
|
|
|
|
|
$dyn = new Dynaform();
|
|
|
|
|
$aFields = $dyn->load( $dynaformUid );
|
|
|
|
|
$xmlFields = $dyn->getDynaformFields( $dynaformUid );
|
|
|
|
|
|
|
|
|
|
$reportTpl = PATH_TPL . 'javaBridgePM/classic.xml';
|
|
|
|
|
$reportFilename = PATH_DYNAFORM . $aFields['PRO_UID'] . PATH_SEP . $outDocUid . '.jrxml';
|
|
|
|
|
foreach ($xmlFields as $key => $val) {
|
2013-03-14 15:50:49 -04:00
|
|
|
if ($val->type == 'submit' || $val->type == 'button' || $val->type == 'title' || $val->type == 'subtitle') {
|
2012-10-09 12:52:35 -04:00
|
|
|
unset( $xmlFields[$key] );
|
2013-03-14 15:50:49 -04:00
|
|
|
}
|
2012-10-09 12:52:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//$sqlSentence = 'SELECT * from ' . $tableName;
|
|
|
|
|
$sqlSentence = 'dynaform/';
|
|
|
|
|
|
|
|
|
|
$template = new TemplatePower( $reportTpl );
|
|
|
|
|
$template->prepare();
|
|
|
|
|
$template->assign( 'sqlSentence', $sqlSentence );
|
|
|
|
|
$template->assign( 'tableName', $aFields['DYN_TITLE'] );
|
|
|
|
|
$template->assign( 'heightDetail', count( $xmlFields ) * 15 + 20 );
|
|
|
|
|
$template->assign( 'PAGE_NUMBER', '{PAGE_NUMBER}' );
|
|
|
|
|
|
|
|
|
|
$logoReporte = 'http://' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . '/images/processmaker.logo.jpg';
|
|
|
|
|
$template->assign( 'logoReporte', $logoReporte );
|
|
|
|
|
|
|
|
|
|
foreach ($xmlFields as $key => $val) {
|
|
|
|
|
$template->newBlock( 'fields' );
|
|
|
|
|
$template->assign( 'fieldName', $key );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$posX = 140;
|
|
|
|
|
$posLabelX = 5;
|
|
|
|
|
$posY = 10;
|
|
|
|
|
foreach ($xmlFields as $key => $val) {
|
|
|
|
|
$template->newBlock( 'detailFields' );
|
|
|
|
|
$template->assign( 'fieldName', '{' . $key . '}' );
|
|
|
|
|
$template->assign( 'fieldLabel', $key );
|
|
|
|
|
$template->assign( 'labelPosX', $posLabelX );
|
|
|
|
|
$template->assign( 'fieldPosX', $posX );
|
|
|
|
|
$template->assign( 'fieldPosY', $posY );
|
|
|
|
|
$posY += 15;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$content = $template->getOutputContent();
|
|
|
|
|
$iSize = file_put_contents( $reportFilename, $content );
|
|
|
|
|
printf( "saved %s bytes in file %s \n", $iSize, $reportFilename );
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
2012-10-09 12:52:35 -04:00
|
|
|
}
|