private String getLink( final String event, final String label, final String css, String defaultValue, String selectedValue, String tooltip) { String status = Utilities.escapeHTML(Utilities.filterOutHTMLTags(tooltip)); StringBuffer link = new StringBuffer(); defaultValue = defaultValue == null ? AbstractChip.FALSE : defaultValue; selectedValue = selectedValue == null ? AbstractChip.TRUE : selectedValue; link.append("<input type=\"hidden\" name=\"" + event + "\" value=\"" + defaultValue + "\" />"); link.append( "<a href=\"#\" onMouseover=\"window.status='" + status + "'; return true;\" onMouseout=\"window.status=''; return true;\" "); if (css != null) { link.append("class=\"" + css + "\" "); } link.append("hidefocus=\"true\" "); link.append( "onclick=\"document.editorForm.elements['" + event + "'].value='" + selectedValue + "';setScrollAndSubmit();return false;\">"); link.append(label); link.append("</a>"); return link.toString(); }
/** * If the appropriate config property is true (hmc.escape.html), all html content in the given * string will be escaped. */ private String escapeHTML(String text) { if (ConfigConstants.getInstance().HTML_ESCAPE) { return Utilities.escapeHTML(text); } else { return text; } }
private Object convertValue( final ClassAttributeAssignmentModel assignment, final String stringValue) { final String typeCode = assignment.getAttributeType().getCode(); if (ClassificationAttributeTypeEnum.BOOLEAN.getCode().equals(typeCode)) { return Boolean.valueOf(stringValue); } else if (ClassificationAttributeTypeEnum.ENUM.getCode().equals(typeCode)) { // YTODO final Item item = JaloSession.getCurrentSession().getItem(PK.parse(stringValue)); final Object value = load(item); validateParameterNotNull(value, "No such value with PK: " + stringValue); return value; } else if (ClassificationAttributeTypeEnum.NUMBER.getCode().equals(typeCode)) { return Double.valueOf(stringValue); } else if (ClassificationAttributeTypeEnum.STRING.getCode().equals(typeCode)) { return stringValue; } else if (ClassificationAttributeTypeEnum.DATE.getCode().equals(typeCode)) { try { return Utilities.getDateTimeInstance().parse(stringValue); } catch (final ParseException e) { throw new IllegalArgumentException(e.getMessage(), e); } } else { throw new IllegalArgumentException("Invalid classifcation attribute type code: " + typeCode); } }
@BeforeClass public static void prepare() throws Exception // NOPMD { Registry.activateStandaloneMode(); Utilities.setJUnitTenant(); LOG.debug("Preparing..."); final ApplicationContext appCtx = Registry.getGlobalApplicationContext(); assertTrue( "Application context of type " + appCtx.getClass() + " is not a subclass of " + ConfigurableApplicationContext.class, appCtx instanceof ConfigurableApplicationContext); final ConfigurableApplicationContext applicationContext = (ConfigurableApplicationContext) appCtx; final ConfigurableListableBeanFactory beanFactory = applicationContext.getBeanFactory(); assertTrue( "Bean Factory of type " + beanFactory.getClass() + " is not of type " + BeanDefinitionRegistry.class, beanFactory instanceof BeanDefinitionRegistry); final XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader((BeanDefinitionRegistry) beanFactory); xmlReader.setDocumentReaderClass(ScopeTenantIgnoreDocReader.class); xmlReader.loadBeanDefinitions( new ClassPathResource( "/merchandisefulfilmentprocess/test/merchandisefulfilmentprocess-spring-test.xml")); xmlReader.loadBeanDefinitions( new ClassPathResource( "/merchandisefulfilmentprocess/test/merchandisefulfilmentprocess-spring-test-fraudcheck.xml")); xmlReader.loadBeanDefinitions( new ClassPathResource( "/merchandisefulfilmentprocess/test/process/order-process-spring.xml")); modelService = (ModelService) getBean("modelService"); processService = (DefaultBusinessProcessService) getBean("businessProcessService"); definitonFactory = processService.getProcessDefinitionFactory(); LOG.warn("Prepare Process Definition factory..."); definitonFactory.add( "classpath:/merchandisefulfilmentprocess/test/process/payment-process.xml"); // setup command factory to mock final DefaultCommandFactoryRegistryImpl commandFactoryReg = appCtx.getBean(DefaultCommandFactoryRegistryImpl.class); commandFactoryReg.setCommandFactoryList( Arrays.asList((CommandFactory) appCtx.getBean("mockupCommandFactory"))); taskServiceStub = appCtx.getBean(TaskServiceStub.class); productService = appCtx.getBean("defaultProductService", DefaultProductService.class); cartService = appCtx.getBean("defaultCartService", DefaultCartService.class); userService = appCtx.getBean("defaultUserService", DefaultUserService.class); }
public void run() { Registry.activateStandaloneMode(); Registry.activateMasterTenant(); final JaloSession jaloSession = JaloSession.getCurrentSession(); System.out.println("Session ID: " + jaloSession.getSessionID()); // NOPMD System.out.println("User: " + jaloSession.getUser()); // NOPMD Utilities.printAppInfo(); RedeployUtilities.shutdown(); }
/* * test deactivated, but this test can show */ public void NOtestBugWithSQL() { Connection conn = null; Statement stmt = null; try { conn = Registry.getCurrentTenant().getDataSource().getConnection(); conn.setAutoCommit(false); stmt = conn.createStatement(); stmt.execute( "INSERT INTO junit_MediaFormat (PK,typepkstring,createdTS,p_qualifier) VALUES (11,1,'98-12-31 11:30:45','11')"); stmt.close(); stmt = null; stmt = conn.createStatement(); stmt.execute( "INSERT INTO junit_MediaFormat (PK,typepkstring,createdTS,p_qualifier) VALUES (11,1,'98-12-31 11:30:45','12')"); stmt.close(); stmt = null; } catch (final Exception e) { System.out.println("exception:" + e.getMessage()); } finally { Utilities.tryToCloseJDBC(null, stmt, null); try { ResultSet rs = null; System.out.println(conn.hashCode()); conn.rollback(); // ACTIVATE THESE LINES TO MAKE IT WORK // ((ConnectionImpl)conn).getUnderlayingConnection().close(); // Registry.getCurrentTenant().getDataSource().invalidate( (ConnectionImpl)conn ); // conn=null; // conn = Registry.getCurrentTenant().getDataSource().getConnection(); // System.out.println(conn.hashCode()); stmt = conn.createStatement(); rs = stmt.executeQuery("SELECT COUNT(*) FROM junit_MediaFormat WHERE PK=11 OR PK=12"); rs.next(); final int cnt = rs.getInt(1); rs.close(); rs = null; stmt.close(); stmt = null; assertEquals("item still alive after rollback!", 0, cnt); } catch (final SQLException e) { // DOCTODO Document reason, why this block is empty } finally { Utilities.tryToCloseJDBC(null, stmt, null); try { stmt = conn.createStatement(); stmt.executeQuery("DELETE FROM junit_mediaFormat WHERE PK=11 OR PK=12"); stmt.close(); stmt = null; } catch (final Exception e) { // DOCTODO Document reason, why this block is empty } finally { Utilities.tryToCloseJDBC(conn, stmt, null); } } } }
private String getSimpleImageConfirmLink( final String event, final String label, final String image, String imageOver, String javascript) { String status = Utilities.escapeHTML(Utilities.filterOutHTMLTags(label)); if ((imageOver == null) || imageOver.equals("")) { imageOver = image; } if ((javascript == null) || javascript.equals("")) { javascript = "true"; } final String imageID = event + "_img"; StringBuffer link = new StringBuffer(); link.append("<input type=\"hidden\" name=\"") .append(event) .append("\" value=\"") .append(AbstractChip.FALSE) .append("\" />"); link.append("<a href=\"#\" hidefocus=\"true\" style=\"text-decoration:none; \" alt=\"") .append(status) .append("\" title=\"") .append(status) .append("\""); link.append("onMouseover=\"window.status='") .append(status) .append("'; swapImage('") .append(imageID) .append("', '") .append(imageOver) .append("'); return true;\" "); link.append("onMouseout=\"window.status=''; swapImage('") .append(imageID) .append("', '") .append(image) .append("'); return true;\" "); link.append("onFocus=\"swapImage('") .append(imageID) .append("', '") .append(imageOver) .append("'); return true;\" "); link.append("onBlur=\"swapImage('") .append(imageID) .append("', '") .append(image) .append("'); return true;\" "); link.append("onclick=\"document.editorForm.elements['") .append(event) .append("'].value = ") .append(javascript) .append("; setScrollAndSubmit(); return false;\">"); link.append("<img id=\"") .append(imageID) .append("\" src=\"") .append(image) .append("\" alt=\"") .append(status) .append("\">"); link.append("</a>"); return link.toString(); }
private String getIconButton( final String event, final String label, final String image, String javascript, boolean showLabel, boolean isEnabled) { String status = Utilities.escapeHTML(Utilities.filterOutHTMLTags(label)); if ((javascript == null) || javascript.equals("")) { javascript = "true"; } final String imageID = event + "_img"; StringBuffer link = new StringBuffer(); final String color = isEnabled ? "#ffffff" : "#D8DCE3"; if (isEnabled) { link.append( "<input type=\"hidden\" name=\"" + event + "\" value=\"" + AbstractChip.FALSE + "\" />"); link.append( "<a href=\"#\" hidefocus=\"true\" style=\"text-decoration:none; \" alt=\"" + status + "\" "); link.append( "onMouseover=\"window.status='" + status + "'; " + " document.getElementById('" + imageID + "_bg_left').style.backgroundImage = 'url(images/icons/icon_button_background_hover_l.gif)'; " + " document.getElementById('" + imageID + "_bg_middle').style.backgroundImage = 'url(images/icons/icon_button_background_hover_m.gif)'; " + " document.getElementById('" + imageID + "_bg_right').style.backgroundImage = 'url(images/icons/icon_button_background_hover_r.gif)'; " + " return true;\" "); link.append( "onMouseout=\"window.status='';" + " document.getElementById('" + imageID + "_bg_left').style.backgroundImage = 'url(images/icons/icon_button_background_l.gif)'; " + " document.getElementById('" + imageID + "_bg_middle').style.backgroundImage = 'url(images/icons/icon_button_background_m.gif)'; " + " document.getElementById('" + imageID + "_bg_right').style.backgroundImage = 'url(images/icons/icon_button_background_r.gif)'; " + " return true;\" "); link.append( "onFocus=\"window.status='" + status + "'; " + " document.getElementById('" + imageID + "_bg_left').style.backgroundImage = 'url(images/icons/icon_button_background_hover_l.gif)'; " + " document.getElementById('" + imageID + "_bg_middle').style.backgroundImage = 'url(images/icons/icon_button_background_hover__m.gif)'; " + " document.getElementById('" + imageID + "_bg_right').style.backgroundImage = 'url(images/icons/icon_button_background_hover__r.gif)'; " + " return true;\" "); link.append( "onBlur=\"window.status='';" + " document.getElementById('" + imageID + "_bg_left').style.backgroundImage = 'url(images/icons/icon_button_background_l.gif)'; " + " document.getElementById('" + imageID + "_bg_middle').style.backgroundImage = 'url(images/icons/icon_button_background_m.gif)'; " + " document.getElementById('" + imageID + "_bg_right').style.backgroundImage = 'url(images/icons/icon_button_background_r.gif)'; " + " return true;\" "); link.append( "onclick=\"document.editorForm.elements['" + event + "'].value = " + javascript + "; setScrollAndSubmit(); return false;\">"); } link.append( "<table title=\"" + status + "\" style=\"vertical-align:middle; width:100%; height:23px; padding:0px;\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">"); link.append("<tr>"); link.append( "<td id=\"" + imageID + "_bg_left\" style=\"width:3px;font-size:1pt;padding:0px;\" background=\"images/icons/icon_button_background_l.gif\"><div style=\"width:3px;\"></div></td>"); link.append( "<td id=\"" + imageID + "_bg_middle\" style=\"white-space:nowrap;vertical-align:middle;text-align:center;padding:0px;\" background=\"images/icons/icon_button_background_m.gif\">"); link.append( "<img id=\"" + imageID + "\" style=\"vertical-align:middle\" src=\"" + image + "\">"); if (showLabel) { link.append("<span style=\"padding-left:5px; color:" + color + "\">" + label + "</span>"); } link.append("</td>"); link.append( "<td id=\"" + imageID + "_bg_right\" style=\"width:3px;font-size:1pt;padding:0px;\" background=\"images/icons/icon_button_background_r.gif\"><div style=\"width:3px;\"></div></td>"); link.append("</tr>"); link.append("</table>"); if (isEnabled) { link.append("</a>"); } return link.toString(); }
@BeforeClass public static void prepare() throws Exception // NOPMD { Registry.activateStandaloneMode(); Utilities.setJUnitTenant(); LOG.debug("Preparing..."); final ApplicationContext appCtx = Registry.getApplicationContext(); // final ConfigurationService configurationService = (ConfigurationService) // appCtx.getBean("configurationService"); // configurationService.getConfiguration().setProperty("processengine.event.lockProcess", // "true"); assertTrue( "Application context of type " + appCtx.getClass() + " is not a subclass of " + ConfigurableApplicationContext.class, appCtx instanceof ConfigurableApplicationContext); final ConfigurableApplicationContext applicationContext = (ConfigurableApplicationContext) appCtx; final ConfigurableListableBeanFactory beanFactory = applicationContext.getBeanFactory(); assertTrue( "Bean Factory of type " + beanFactory.getClass() + " is not of type " + BeanDefinitionRegistry.class, beanFactory instanceof BeanDefinitionRegistry); final XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader((BeanDefinitionRegistry) beanFactory); xmlReader.setDocumentReaderClass(ScopeTenantIgnoreDocReader.class); xmlReader.loadBeanDefinitions( new ClassPathResource( "/octannerfulfilmentprocess/test/octannerfulfilmentprocess-spring-test.xml")); xmlReader.loadBeanDefinitions( new ClassPathResource("/octannerfulfilmentprocess/test/process/order-process-spring.xml")); xmlReader.loadBeanDefinitions( new ClassPathResource( "/octannerfulfilmentprocess/test/process/consignment-process-spring.xml")); modelService = (ModelService) getBean("modelService"); processService = (DefaultBusinessProcessService) getBean("businessProcessService"); definitonFactory = processService.getProcessDefinitionFactory(); LOG.warn("Prepare Process Definition factory..."); definitonFactory.add("classpath:/octannerfulfilmentprocess/test/process/order-process.xml"); definitonFactory.add( "classpath:/octannerfulfilmentprocess/test/process/consignment-process.xml"); LOG.warn( "loaded 'order-process-test':" + definitonFactory.getProcessDefinition("order-process-test") + " in factory " + definitonFactory); // setup command factory to mock taskServiceStub = appCtx.getBean(TaskServiceStub.class); processService.setTaskService(taskServiceStub); final DefaultCommandFactoryRegistryImpl commandFactoryReg = appCtx.getBean(DefaultCommandFactoryRegistryImpl.class); commandFactoryReg.setCommandFactoryList( Arrays.asList((CommandFactory) appCtx.getBean("mockupCommandFactory"))); }