private String getSchemaPackageDirectory() { final String modelPackage = EntityTypesCache.instance.getModelPackage(p_EntityType); Check.assumeNotEmpty(modelPackage, "Entity type " + p_EntityType + " has a ModelPackage set"); final int idx = modelPackage.indexOf(".model"); return modelPackage.substring(0, idx).replace(".", "/"); }
@Override public void allocateAllMRPDemands(final List<IMRPSuppliesPool> mrpSuppliesPools) { Check.assumeNotEmpty(mrpSuppliesPools, "mrpSuppliesPools not empty"); // // Iterate each existing MRP demand that needs to be allocated final Iterator<IMutableMRPRecordAndQty> mrpDemandsToAllocateIterator = mrpDemandsToAllocate.iterator(); while (mrpDemandsToAllocateIterator.hasNext()) { final IMutableMRPRecordAndQty mrpDemand = mrpDemandsToAllocateIterator.next(); // // Iterate each MRP supplies pool and ask to allocate for (final IMRPSuppliesPool mrpSuppliesPool : mrpSuppliesPools) { // Check if the MRP demand was fully allocated. If it was there is no point to try // allocating it. if (mrpDemand.isZeroQty()) { break; } // Ask current MRP supplies pool to allocate it final List<IMRPDemandToSupplyAllocation> mrpDemandAllocations = mrpSuppliesPool.allocate(mrpDemand); addAllocationsPerformed(mrpDemandAllocations); } } }
@Override public Result processWorkPackage( final I_C_Queue_WorkPackage workPackage, final String localTrxName) { final ILoggable loggable = getLoggable(); final IParams params = getParameters(); // // Extract param: SQL code to execute (and normalize it) final String sqlRaw = params.getParameterAsString(PARAM_Code); Check.assumeNotEmpty(sqlRaw, "Missing parameter: {}", PARAM_Code); final String sql = parseSql(sqlRaw, workPackage); loggable.addLog("SQL to execute: {0}", sql); // // Extract param: ReEnqueue final boolean isReEnqueue = params.hasParameter(PARAM_ReEnqueue) ? params.getParameterAsBool(PARAM_ReEnqueue) : DEFAULT_ReEnqueue; // // Execute the SQL update final int updateCount = executeSql(sql, localTrxName); loggable.addLog("Updated {0} records", updateCount); // // Re-enqueue the Workpackage if there was something updated and if we are asked to do so if (updateCount > 0) { if (isReEnqueue) { final Properties ctx = InterfaceWrapperHelper.getCtx(workPackage); final I_C_Queue_WorkPackage nextWorkpackage = Services.get(IWorkPackageQueueFactory.class) .getQueueForEnqueuing(ctx, getClass()) .newBlock() .setContext(ctx) .newWorkpackage() .bindToTrxName(localTrxName) // // Workpackage Parameters .parameters() .setParameter(PARAM_Code, sql) .end() // // Build & enqueue .build(); loggable.addLog("New workpackage enqueued: {0}", nextWorkpackage); } else { loggable.addLog( "No new workpackages will be reenqueued because parameter {0} is false", PARAM_ReEnqueue); } } else { loggable.addLog( "No new workpackages will be reenqueued because there was nothing updated in this run"); } return Result.SUCCESS; }
@Override public String TO_SEQUENCE_NEXTVAL(final String sequenceName) { Check.assumeNotEmpty(sequenceName, "sequenceName not empty"); final StringBuilder sb = new StringBuilder(); sb.append(sequenceName).append(".nextval"); return sb.toString(); }
public MutableTableCacheConfig(final String tableName) { super(); Check.assumeNotEmpty(tableName, "tableName not empty"); this.tableName = tableName; this.enabled = true; // enable it by default this.trxLevel = TrxLevel.All; this.cacheMapType = CacheMapType.HashMap; }
private EntityTypeEntry getEntityTypeEntryOrNull(final String entityType) { Check.assumeNotEmpty( entityType, "entityType not empty"); // fail because in most of the cases is a development error loadIfNeeded(); final EntityTypeEntry entry = cache.get(entityType); return entry; }
private EntityTypeEntry(final Builder builder) { super(); this.entityType = builder.entityType; Check.assumeNotEmpty(entityType, "entityType not empty"); this.modelPackage = builder.modelPackage; this.displayedInUI = builder.displayedInUI; this.systemMaintained = builder.systemMaintained; this.webUIServletListenerClass = builder.webUIServletListenerClass; }
public final IInfoQueryCriteria getParameterByColumnNameOrNull(final String columnName) { Check.assumeNotEmpty(columnName, "columnName not null"); for (final IInfoQueryCriteria param : displayedParameters) { final I_AD_InfoColumn infoColumn = param.getAD_InfoColumn(); final String infoColumnName = infoColumn.getColumnName(); if (columnName.equals(infoColumnName)) { return param; } } return null; }
public final Collector setParameter(final String parameterName, final Object parameterValue) { assertNotProcessed(); Check.assumeNotEmpty(parameterName, "parameterName not empty"); final Object oldValue = parameters.put(parameterName, parameterValue); Check.errorIf( oldValue != null // gh #409: it's ok if an equal value is added more than once. This for example // happens if an inout is reversed, because there the counter doc's model interceptor // is fired twice within the same transaction. && !oldValue.equals(parameterValue), "Illegal attempt to overwrite parameter name={} with newValue={}; it was already set to oldValue={}", parameterName, parameterValue, oldValue); return this; }
public static void main(final String[] args) { // // Start ADempiere AdempiereToolsHelper.getInstance().startupMinimal(); LogManager.setLevel(Level.DEBUG); Ini.setProperty(Ini.P_LOGMIGRATIONSCRIPT, false); // metas: don't log migration scripts final TableAndColumnInfoRepository repository = new TableAndColumnInfoRepository(); // // Get AD_Reference_ID parameter if (args.length < 1) { throw new AdempiereException("Provide AD_Reference_ID parameter"); } final String adReferenceIdStr = args[0]; Check.assumeNotEmpty(adReferenceIdStr, "Valid AD_Reference_ID parameter: {}", adReferenceIdStr); final int adReferenceId = Integer.parseInt(adReferenceIdStr.trim()); // // Get the AD_Reference list info final ListInfo listInfo = repository.getListInfo(adReferenceId).orNull(); if (listInfo == null) { throw new AdempiereException("No list info found for AD_Reference_ID=" + adReferenceId); } // // Generate the Java code final String javacode = ADRefListGenerator.newInstance() .setColumnName("MyColumnName") .setListInfo(listInfo) .generateConstants(); // // Output the result System.out.println("Generated Java code:"); System.out.println( "--------------------------------------------------------------------------------------------"); System.out.println(javacode); System.out.println( "--------------------------------------------------------------------------------------------"); }
@Override public <T extends IInfoColumnController> T getInfoColumnControllerOrNull( final String columnName, final Class<T> controllerClass) { Check.assumeNotEmpty(columnName, "columnName not empty"); Check.assumeNotNull(controllerClass, "controllerClass not empty"); final int column = getColumnIndex(columnName); if (column < 0) { return null; } final Info_Column infoColumn = p_layout[column]; final IInfoColumnController controller = infoColumn.getColumnController(); if (controller == null) { return null; } if (!controllerClass.isAssignableFrom(controller.getClass())) { return null; } return controllerClass.cast(controller); }
/* package */ String getMRPCode_ToUse() { Check.assumeNotEmpty(_mrpCode, "mrpCode not empty"); return _mrpCode; }
public static final LockOwner forOwnerName(final String ownerName) { Check.assumeNotEmpty(ownerName, "ownerName not empty"); return new LockOwner(ownerName, OwnerType.RealOwner); }
/** * Put given variable to context. * * <p>In case the test will fail, all context variables will be printed to console. * * @param name * @param value */ public void putContext(final String name, final Object value) { Check.assumeNotEmpty(name, "name is not empty"); context.put(name, value); }
@Override public IMRPNoteBuilder addParameter(final String parameterName, final Object parameterValue) { Check.assumeNotEmpty(parameterName, "parameterName not empty"); _parameters.put(parameterName, parameterValue); return this; }
public void setThrowExceptionOnNewChunk(final String groupKey) { Check.assumeNotEmpty(groupKey, "groupKey not null"); errorOnNewChunkGroupKeys.add(groupKey); }
public static IHostIdentifier of(final String hostOrAddress) throws UnknownHostException { Check.assumeNotEmpty(hostOrAddress, "hostOrAddress not empty"); final InetAddress inetAddress = InetAddress.getByName(hostOrAddress); return of(inetAddress); }
private String getAction() { Check.assumeNotEmpty(action, "action not empty"); return action; }