CODE STYLE class.javaBridgePM.php

This commit is contained in:
Fernando Ontiveros
2012-10-09 12:52:35 -04:00
parent ace3ab8006
commit f2ec274099

View File

@@ -1,6 +1,7 @@
<?php <?php
/** /**
* class.javaBridgePM.php * class.javaBridgePM.php
*
* @package workflow.engine.classes * @package workflow.engine.classes
* *
* ProcessMaker Open Source Edition * ProcessMaker Open Source Edition
@@ -23,12 +24,15 @@
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/ */
if (! defined( 'JAVA_BRIDGE_PATH' ))
if ( ! defined ( 'JAVA_BRIDGE_PATH') ) define ( 'JAVA_BRIDGE_PATH', 'JavaBridgePM' ); define( 'JAVA_BRIDGE_PATH', 'JavaBridgePM' );
if ( ! defined ( 'JAVA_BRIDGE_PORT') ) define ( 'JAVA_BRIDGE_PORT', '8080' ); if (! defined( 'JAVA_BRIDGE_PORT' ))
if ( ! defined ( 'JAVA_BRIDGE_HOST') ) define ( 'JAVA_BRIDGE_HOST', '127.0.0.1' ); define( 'JAVA_BRIDGE_PORT', '8080' );
if (! defined( 'JAVA_BRIDGE_HOST' ))
define( 'JAVA_BRIDGE_HOST', '127.0.0.1' );
/** /**
*
* @package workflow.engine.classes * @package workflow.engine.classes
*/ */
class JavaBridgePM class JavaBridgePM
@@ -41,6 +45,7 @@
* checkJavaExtension * checkJavaExtension
* check if the java extension was loaded. * check if the java extension was loaded.
* *
*
* @return true or false * @return true or false
*/ */
function checkJavaExtension () function checkJavaExtension ()
@@ -53,7 +58,8 @@
$includedFiles = get_included_files(); $includedFiles = get_included_files();
$found = false; $found = false;
foreach ($includedFiles as $filename) { foreach ($includedFiles as $filename) {
if ( $urlJavaInc == $filename ) $found = true; if ($urlJavaInc == $filename)
$found = true;
} }
if (! $found) { if (! $found) {
throw new Exception( 'The PHP/Java Bridge is not defined' ); throw new Exception( 'The PHP/Java Bridge is not defined' );
@@ -68,14 +74,14 @@
} }
return true; return true;
} } catch (Exception $e) {
catch ( Exception $e ) {
throw new Exception( 'Error in checkJavaExtension: ' . $e->getMessage() ); throw new Exception( 'Error in checkJavaExtension: ' . $e->getMessage() );
} }
} }
/** /**
* convert a php value to a java one... * convert a php value to a java one...
*
* @param string $value * @param string $value
* @param string $className * @param string $className
* @return s boolean success * @return s boolean success
@@ -88,42 +94,33 @@
if ($className == 'java.lang.String') { if ($className == 'java.lang.String') {
$temp = new Java( 'java.lang.String', $value ); $temp = new Java( 'java.lang.String', $value );
return $temp; return $temp;
} } else if ($className == 'java.lang.Boolean' || $className == 'java.lang.Integer' || $className == 'java.lang.Long' || $className == 'java.lang.Short' || $className == 'java.lang.Double' || $className == 'java.math.BigDecimal') {
else if ($className == 'java.lang.Boolean' ||
$className == 'java.lang.Integer' ||
$className == 'java.lang.Long' ||
$className == 'java.lang.Short' ||
$className == 'java.lang.Double' ||
$className == 'java.math.BigDecimal') {
$temp = new Java( $className, $value ); $temp = new Java( $className, $value );
return $temp; return $temp;
} } else if ($className == 'java.sql.Timestamp' || $className == 'java.sql.Time') {
else if ($className == 'java.sql.Timestamp' ||
$className == 'java.sql.Time') {
$temp = new Java( $className ); $temp = new Java( $className );
$javaObject = $temp->valueOf( $value ); $javaObject = $temp->valueOf( $value );
return $javaObject; return $javaObject;
} }
} } catch (Exception $err) {
catch (Exception $err) { echo ('unable to convert value, ' . $value . ' could not be converted to ' . $className);
echo ( 'unable to convert value, ' . $value .
' could not be converted to ' . $className);
return false; return false;
} }
echo ( 'unable to convert value, class name '.$className. echo ('unable to convert value, class name ' . $className . ' not recognised');
' not recognised');
return false; return false;
} }
/** /**
* generateJrxmlFromDynaform * generateJrxmlFromDynaform
*
* @param string $outDocUid * @param string $outDocUid
* @param string $dynaformUid * @param string $dynaformUid
* @param object $template * @param object $template
* @return void * @return void
*/ */
function generateJrxmlFromDynaform ( $outDocUid, $dynaformUid, $template ) { function generateJrxmlFromDynaform ($outDocUid, $dynaformUid, $template)
{
require_once 'classes/model/Dynaform.php'; require_once 'classes/model/Dynaform.php';
$dyn = new Dynaform(); $dyn = new Dynaform();
$aFields = $dyn->load( $dynaformUid ); $aFields = $dyn->load( $dynaformUid );
@@ -146,8 +143,7 @@
$template->assign( 'heightDetail', count( $xmlFields ) * 15 + 20 ); $template->assign( 'heightDetail', count( $xmlFields ) * 15 + 20 );
$template->assign( 'PAGE_NUMBER', '{PAGE_NUMBER}' ); $template->assign( 'PAGE_NUMBER', '{PAGE_NUMBER}' );
$logoReporte = 'http://' .$_SERVER['SERVER_NAME'] . ':' .$_SERVER['SERVER_PORT'] . $logoReporte = 'http://' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . '/images/processmaker.logo.jpg';
'/images/processmaker.logo.jpg';
$template->assign( 'logoReporte', $logoReporte ); $template->assign( 'logoReporte', $logoReporte );
foreach ($xmlFields as $key => $val) { foreach ($xmlFields as $key => $val) {
@@ -155,7 +151,6 @@
$template->assign( 'fieldName', $key ); $template->assign( 'fieldName', $key );
} }
$posX = 140; $posX = 140;
$posLabelX = 5; $posLabelX = 5;
$posY = 10; $posY = 10;