public LockTableDescriptor(TypeDescriptor type) { Assert.condition(type.isDistinctLockTableName(), "Type must support lock table option."); this.type = type; Assert.condition( !StringUtils.isEmpty(type.getTableAlias()), "Type must have a default alias defined."); this.tableAlias = type.getTableAlias() + "_lck"; }
public long getNextSequence(TypeDescriptor typeDescriptor, Session session) { // check if there is an id in the cache ConcurrentLinkedQueue cachedIds = (ConcurrentLinkedQueue) this.typeDescriptorToIdCache.get(typeDescriptor); if (null == cachedIds) { typeDescriptorToIdCache.putIfAbsent(typeDescriptor, new ConcurrentLinkedQueue()); cachedIds = (ConcurrentLinkedQueue) this.typeDescriptorToIdCache.get(typeDescriptor); } Number cachedId = (Number) cachedIds.poll(); if (cachedId == null) { synchronized (cachedIds) { cachedId = (Number) cachedIds.poll(); if (cachedId == null) { List newIds = this.getNextSequenceImpl(typeDescriptor, session); Assert.condition(0 < newIds.size()); // reserve first for own use cachedId = (Number) newIds.remove(0); cachedIds.addAll(newIds); } } } if (trace.isDebugEnabled()) { trace.debug("returning unique ID: " + cachedId.longValue()); } return cachedId.longValue(); }
/** Check mandatory and isEditable to set color settings. */ protected void performFlags() { Assert.isNotNull(moneyField); Assert.isNotNull(flagLabel); if (isReadonly()) { moneyField.setBackground(SystemColor.control); flagLabel.setIcon(GUI.getOptionalIcon()); } else { // @todo find appropriate system color moneyField.setBackground(Color.white); if (mandatory && getObjectValue() == null) { flagLabel.setIcon(GUI.getMandatoryIcon()); } else { flagLabel.setIcon(GUI.getOptionalIcon()); } } }
public TransitionTokenDigest(TransitionTokenBean transitionToken) { super(null); Assert.isNotNull(transitionToken); oid = transitionToken.getOID(); isConsumed = Boolean.valueOf(transitionToken.isConsumed()).booleanValue(); ITransition transition = transitionToken.getTransition(); IModel model = transition == null ? null : (IModel) transition.getModel(); transitionId = transition == null ? null : "{" + model.getId() + '}' + transition.getId(); // $NON-NLS-1$ procDefId = transition == null ? null : "{" + model.getId() + '}' + transition.getProcessDefinition().getId(); // $NON-NLS-1$ }
private List getNextSequenceImpl(TypeDescriptor typeDescriptor, Session session) { Field[] pkFields = typeDescriptor.getPkFields(); Assert.condition( 1 == pkFields.length, "Automatic PK values are only supported for types with a single PK field."); String createPKStmt = dbDescriptor.getCreatePKStatement( sqlUtils.getSchemaName(), typeDescriptor.getPkSequence(), this.sequenceBatchSize); Field field = pkFields[0]; if (session.isUsingPreparedStatements(typeDescriptor.getType())) { PreparedStatement pkStatement = null; try { Connection connection = session.getConnection(); PreparedStatement result; try { result = connection.prepareStatement(createPKStmt); } catch (SQLException x) { throw new InternalException(x); } pkStatement = result; ResultSet pkQuery = pkStatement.executeQuery(); List newIds = new LinkedList(); while (pkQuery.next()) { newIds.add( DmlManager.getJavaValue( field.getType(), typeDescriptor.getPersistentField(field).getLength(), pkQuery, 1, true, false)); } return newIds; } catch (SQLException e) { throw new InternalException(e); } finally { QueryUtils.closeStatement(pkStatement); } } else { Statement pkStmt = null; try { Connection connection = session.getConnection(); pkStmt = connection.createStatement(); ResultSet pkQuery = pkStmt.executeQuery(createPKStmt); List newIds = new LinkedList(); while (pkQuery.next()) { newIds.add( DmlManager.getJavaValue( field.getType(), typeDescriptor.getPersistentField(field).getLength(), pkQuery, 1, true, false)); } return newIds; } catch (SQLException e) { throw new InternalException(e); } finally { QueryUtils.closeStatement(pkStmt); } } }