List of usage examples for java.io Serializable toString
public String toString()
From source file:gr.abiss.calipso.jpasearch.service.impl.AbstractAclAwareServiceImpl.java
protected void createAclObjectIdentity(T saved, Class domainClass) { if (AclObject.class.isAssignableFrom(domainClass)) { AclObject<ID, ID> aclObject = (AclObject<ID, ID>) saved; AclClass aclClass = this.aclClassRepository.findByClassName(domainClass.getName()); Serializable sid = aclObject.getOwner(); AclSid aclSid = null;//from w ww. j av a 2 s . co m // use current principal as owner? if (sid == null) { UserDetails userDetails = SecurityUtil.getPrincipal(); if (userDetails != null) { sid = userDetails.getUsername(); } } // add owner if any if (sid != null) { aclSid = this.aclSidRepository.findBySid(sid.toString()); } // TODO: parent this.aclObjectIdentityRepository.save(new AclObjectIdentity(aclObject.getIdentity().toString(), aclClass, null, aclSid, aclObject.getEntriesInheriting())); } }
From source file:org.bonitasoft.forms.server.api.impl.FormExpressionsAPIImplIT.java
@Test public void evaluate_expression_on_finished_activity_should_TODO() throws Exception { final ProcessVariable aVariable = aStringVariable("application", "Word"); final TestProcess testProcess = TestProcessFactory.createProcessWithVariables("aProcess1", aVariable); final TestHumanTask executedTask = testProcess.addActor(getInitiator()).enable().startCase() .getNextHumanTask().assignTo(getInitiator()).execute(); final Map<String, FormFieldValue> fieldValues = createFieldValueForVariable(aVariable, "Excel"); final Serializable evaluationResult = formExpressionsAPI.evaluateActivityExpression(getSession(), executedTask.getId(), expression, fieldValues, Locale.ENGLISH, false); assertEquals("Word-Excel", evaluationResult.toString()); }
From source file:org.bonitasoft.forms.server.api.impl.FormExpressionsAPIImplIT.java
@Test public void testEvaluateExpressionOnInstanceWithCurrentValues() throws Exception { Assert.assertTrue("no pending user task instances are found", new WaitUntil(50, 3000) { @Override/*ww w . ja va 2s. c o m*/ protected boolean check() throws Exception { return processAPI.getPendingHumanTaskInstances( FormExpressionsAPIImplIT.this.getSession().getUserId(), 0, 10, null).size() >= 1; } }.waitUntil()); final HumanTaskInstance humanTaskInstance = processAPI .getPendingHumanTaskInstances(getSession().getUserId(), 0, 1, ActivityInstanceCriterion.NAME_ASC) .get(0); final long activityInstanceId = humanTaskInstance.getId(); processAPI.assignUserTask(activityInstanceId, getSession().getUserId()); processAPI.executeFlowNode(activityInstanceId); processAPI.updateProcessDataInstance("application", processInstance.getId(), "Excel"); final List<Expression> dependencies = new ArrayList<Expression>(); dependencies.add(new Expression("application", "application", ExpressionType.TYPE_VARIABLE.name(), String.class.getName(), null, null)); final Expression expression = new Expression(null, "application", ExpressionType.TYPE_READ_ONLY_SCRIPT.name(), String.class.getName(), "GROOVY", dependencies); final Serializable result = formExpressionsAPI.evaluateInstanceInitialExpression(getSession(), processInstance.getId(), expression, Locale.ENGLISH, true); Assert.assertEquals("Excel", result.toString()); }
From source file:org.soybeanMilk.web.os.DefaultWebObjectSource.java
public void set(Serializable key, Object obj) throws ObjectSourceException { if (key == null) throw new IllegalArgumentException("[key] must not be null"); String strKey = (key instanceof String ? (String) key : key.toString()); String[] scopedKeys = SbmUtils.splitByFirstAccessor(strKey); if (WebConstants.Scope.REQUEST.equalsIgnoreCase(scopedKeys[0])) { if (scopedKeys.length > 1) getRequest().setAttribute(scopedKeys[1], obj); else/*from w w w. j a v a 2 s . c om*/ throw new ObjectSourceException( "key " + SbmUtils.toString(key) + " is illegal, you can not replace " + SbmUtils.toString(WebConstants.Scope.REQUEST) + " scope object"); } else if (WebConstants.Scope.SESSION.equalsIgnoreCase(scopedKeys[0])) { if (scopedKeys.length > 1) getRequest().getSession().setAttribute(scopedKeys[1], obj); else throw new ObjectSourceException( "key " + SbmUtils.toString(key) + " is illegal, you can not replace " + SbmUtils.toString(WebConstants.Scope.SESSION) + " scope object"); } else if (WebConstants.Scope.APPLICATION.equalsIgnoreCase(scopedKeys[0])) { if (scopedKeys.length > 1) getApplication().setAttribute(scopedKeys[1], obj); else throw new ObjectSourceException( "key " + SbmUtils.toString(key) + " is illegal, you can not replace " + SbmUtils.toString(WebConstants.Scope.APPLICATION) + " scope object"); } else if (WebConstants.Scope.PARAM.equalsIgnoreCase(scopedKeys[0])) { throw new ObjectSourceException("key " + SbmUtils.toString(key) + " is illegal, set object to " + SbmUtils.toString(WebConstants.Scope.PARAM) + " scope is not supported"); } else if (WebConstants.Scope.RESPONSE.equalsIgnoreCase(scopedKeys[0])) { throw new ObjectSourceException("key " + SbmUtils.toString(key) + " is illegal, set object to " + SbmUtils.toString(WebConstants.Scope.RESPONSE) + " scope is not supported"); } else if (WebConstants.Scope.OBJECT_SOURCE.equalsIgnoreCase(scopedKeys[0])) { throw new ObjectSourceException("key " + SbmUtils.toString(key) + " is illegal, set object to " + SbmUtils.toString(WebConstants.Scope.OBJECT_SOURCE) + " scope is not supported"); } else setObjectWithScopeUnknownKey(strKey, obj); if (log.isDebugEnabled()) log.debug("set object " + SbmUtils.toString(obj) + " to " + SbmUtils.toString(this) + " with key " + SbmUtils.toString(strKey)); }
From source file:org.bonitasoft.forms.server.api.impl.FormExpressionsAPIImplIT.java
@Test public void evaluate_expression_on_activity_should_TODO() throws Exception { final ProcessVariable aVariable = aStringVariable("application", "Word"); final TestProcess testProcess = TestProcessFactory.createProcessWithVariables("aProcess2", aVariable); final TestHumanTask notExecutedTask = testProcess.addActor(getInitiator()).enable().startCase() .getNextHumanTask().assignTo(getInitiator()); final Map<String, FormFieldValue> fieldValues = createFieldValueForVariable(aVariable, "Excel"); final Serializable evaluationResult = formExpressionsAPI.evaluateActivityExpression(getSession(), notExecutedTask.getId(), expression, fieldValues, Locale.ENGLISH, false); assertEquals("Word-Excel", evaluationResult.toString()); }
From source file:org.bonitasoft.forms.server.api.impl.FormExpressionsAPIImplIT.java
@Test public void testEvaluateExpressionOnInstanceWithInitialValues() throws Exception { Assert.assertTrue("no pending user task instances are found", new WaitUntil(50, 3000) { @Override//from w w w . j a va 2 s . c o m protected boolean check() throws Exception { return processAPI.getPendingHumanTaskInstances( FormExpressionsAPIImplIT.this.getSession().getUserId(), 0, 10, null).size() >= 1; } }.waitUntil()); final HumanTaskInstance humanTaskInstance = processAPI .getPendingHumanTaskInstances(getSession().getUserId(), 0, 1, ActivityInstanceCriterion.NAME_ASC) .get(0); final long activityInstanceId = humanTaskInstance.getId(); processAPI.assignUserTask(activityInstanceId, getSession().getUserId()); processAPI.executeFlowNode(activityInstanceId); processAPI.updateProcessDataInstance("application", processInstance.getId(), "Excel"); final List<Expression> dependencies = new ArrayList<Expression>(); dependencies.add(new Expression("application", "application", ExpressionType.TYPE_VARIABLE.name(), String.class.getName(), null, null)); final Expression expression = new Expression(null, "application", ExpressionType.TYPE_READ_ONLY_SCRIPT.name(), String.class.getName(), "GROOVY", dependencies); Assert.assertTrue("no pending user task instances are found", new WaitUntil(50, 3000) { @Override protected boolean check() throws Exception { return processAPI.getPendingHumanTaskInstances( FormExpressionsAPIImplIT.this.getSession().getUserId(), 0, 10, null).size() >= 1; } }.waitUntil()); final Serializable result = formExpressionsAPI.evaluateInstanceInitialExpression(getSession(), processInstance.getId(), expression, Locale.ENGLISH, false); Assert.assertEquals("Word", result.toString()); }
From source file:org.pentaho.platform.repository2.unified.jcr.JcrRepositoryFileUtils.java
public static Node deleteFileLocaleProperties(final Session session, final Serializable fileId, String locale) throws RepositoryException { PentahoJcrConstants pentahoJcrConstants = new PentahoJcrConstants(session); Node fileNode = session.getNodeByIdentifier(fileId.toString()); String prefix = session.getNamespacePrefix(PentahoJcrConstants.PHO_NS); Assert.hasText(prefix);/*from ww w . j a v a 2 s. c om*/ Node localesNode = fileNode.getNode(pentahoJcrConstants.getPHO_LOCALES()); Assert.notNull(localesNode); try { // remove locale node Node localeNode = NodeHelper.checkGetNode(localesNode, locale); localeNode.remove(); } catch (PathNotFoundException pnfe) { // nothing to delete } return fileNode; }
From source file:com.pentaho.repository.importexport.StreamToTransNodeConverter.java
/** * //from w w w . j av a2 s. com * @param fileId * @return */ public InputStream convert(final Serializable fileId) { try { // this will change in the future if PDI no longer has its // own repository. For now, get the reference if (fileId != null) { Repository repository = connectToRepository(); RepositoryFile file = unifiedRepository.getFileById(fileId); if (file != null) { try { TransMeta transMeta = repository.loadTransformation(new StringObjectId(fileId.toString()), null); if (transMeta != null) { Set<String> privateDatabases = transMeta.getPrivateDatabases(); if (privateDatabases != null) { // keep only private transformation databases for (Iterator<DatabaseMeta> it = transMeta.getDatabases().iterator(); it .hasNext();) { String databaseName = it.next().getName(); if (!privateDatabases.contains(databaseName)) { it.remove(); } } } return new ByteArrayInputStream(transMeta.getXML().getBytes()); } } catch (KettleException e) { logger.error(e); // file is there and may be legacy, attempt simple export SimpleRepositoryFileData fileData = unifiedRepository.getDataForRead(fileId, SimpleRepositoryFileData.class); if (fileData != null) { logger.warn("Reading as legacy CE tranformation " + file.getName() + "."); return fileData.getInputStream(); } } } } } catch (Exception e) { logger.error(e); } return null; }
From source file:org.grails.orm.hibernate.HibernateDatastore.java
/** * Create a new HibernateDatastore for the given connection sources and mapping context * * @param connectionSources The {@link ConnectionSources} instance * @param mappingContext The {@link MappingContext} instance * @param eventPublisher The {@link ConfigurableApplicationEventPublisher} instance *///from ww w.ja v a 2s . c om public HibernateDatastore( final ConnectionSources<SessionFactory, HibernateConnectionSourceSettings> connectionSources, final HibernateMappingContext mappingContext, final ConfigurableApplicationEventPublisher eventPublisher) { super(connectionSources, mappingContext); GrailsHibernateTransactionManager hibernateTransactionManager = new GrailsHibernateTransactionManager(); HibernateConnectionSource defaultConnectionSource = (HibernateConnectionSource) connectionSources .getDefaultConnectionSource(); hibernateTransactionManager.setDataSource(defaultConnectionSource.getDataSource()); hibernateTransactionManager.setSessionFactory(defaultConnectionSource.getSource()); this.transactionManager = hibernateTransactionManager; this.eventPublisher = eventPublisher; this.eventTriggeringInterceptor = new EventTriggeringInterceptor(this); HibernateConnectionSourceSettings settings = defaultConnectionSource.getSettings(); HibernateConnectionSourceSettings.HibernateSettings hibernateSettings = settings.getHibernate(); ClosureEventTriggeringInterceptor interceptor = (ClosureEventTriggeringInterceptor) hibernateSettings .getEventTriggeringInterceptor(); interceptor.setDatastore(this); interceptor.setEventPublisher(eventPublisher); registerEventListeners(this.eventPublisher); configureValidatorRegistry(settings, mappingContext); this.mappingContext.addMappingContextListener(new MappingContext.Listener() { @Override public void persistentEntityAdded(PersistentEntity entity) { gormEnhancer.registerEntity(entity); } }); initializeConverters(this.mappingContext); if (!(connectionSources instanceof SingletonConnectionSources)) { Iterable<ConnectionSource<SessionFactory, HibernateConnectionSourceSettings>> allConnectionSources = connectionSources .getAllConnectionSources(); for (ConnectionSource<SessionFactory, HibernateConnectionSourceSettings> connectionSource : allConnectionSources) { SingletonConnectionSources<SessionFactory, HibernateConnectionSourceSettings> singletonConnectionSources = new SingletonConnectionSources<>( connectionSource, connectionSources.getBaseConfiguration()); HibernateDatastore childDatastore; if (ConnectionSource.DEFAULT.equals(connectionSource.getName())) { childDatastore = this; } else { childDatastore = new HibernateDatastore(singletonConnectionSources, mappingContext, eventPublisher) { @Override protected HibernateGormEnhancer initialize() { return null; } }; } datastoresByConnectionSource.put(connectionSource.getName(), childDatastore); } if (multiTenantMode == MultiTenancySettings.MultiTenancyMode.SCHEMA) { if (this.tenantResolver instanceof AllTenantsResolver) { AllTenantsResolver allTenantsResolver = (AllTenantsResolver) tenantResolver; Iterable<Serializable> tenantIds = allTenantsResolver.resolveTenantIds(); for (Serializable tenantId : tenantIds) { addTenantForSchemaInternal(tenantId.toString()); } } else { Collection<String> allSchemas = schemaHandler .resolveSchemaNames(defaultConnectionSource.getDataSource()); for (String schema : allSchemas) { addTenantForSchemaInternal(schema); } } } } this.gormEnhancer = initialize(); this.eventPublisher.publishEvent(new DatastoreInitializedEvent(this)); }
From source file:org.bonitasoft.forms.server.api.impl.FormExpressionsAPIImplIT.java
@Test public void testEvaluateExpressionOnProcessWithTransiantData() throws Exception { final Expression transientDataExpression = new Expression(null, "transientData", ExpressionType.TYPE_INPUT.name(), String.class.getName(), null, null); final List<Expression> dependencies = new ArrayList<Expression>(); dependencies.add(transientDataExpression); final Expression expressionToEvaluate = new Expression(null, "transientData", ExpressionType.TYPE_READ_ONLY_SCRIPT.name(), String.class.getName(), "GROOVY", dependencies); final Map<String, Serializable> context = new HashMap<String, Serializable>(); context.put("transientData", "transientDataValue"); final Serializable result = formExpressionsAPI.evaluateProcessInitialExpression(getSession(), processDefinition.getId(), expressionToEvaluate, Locale.ENGLISH, context); Assert.assertEquals("transientDataValue", result.toString()); }