本文整理汇总了Java中org.compiere.util.Env类的典型用法代码示例。如果您正苦于以下问题:Java Env类的具体用法?Java Env怎么用?Java Env使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Env类属于org.compiere.util包,在下文中一共展示了Env类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: retrieveUserDashboardId
import org.compiere.util.Env; //导入依赖的package包/类
private int retrieveUserDashboardId(final UserDashboardKey key)
{
final int adClientId = key.getAdClientId();
final int dashboardId = queryBL
.createQueryBuilder(I_WEBUI_Dashboard.class)
.addOnlyActiveRecordsFilter()
.addInArrayFilter(I_WEBUI_Dashboard.COLUMN_AD_Client_ID, Env.CTXVALUE_AD_Client_ID_System, adClientId)
//
.orderBy()
.addColumn(I_WEBUI_Dashboard.COLUMN_AD_Client_ID, Direction.Descending, Nulls.Last)
.addColumn(I_WEBUI_Dashboard.COLUMN_IsDefault, Direction.Descending, Nulls.Last)
.addColumn(I_WEBUI_Dashboard.COLUMN_WEBUI_Dashboard_ID)
.endOrderBy()
//
.create()
.firstId();
return dashboardId > 0 ? dashboardId : -1;
}
示例2: getKPIOrNull
import org.compiere.util.Env; //导入依赖的package包/类
KPI getKPIOrNull(final int WEBUI_KPI_ID)
{
if (WEBUI_KPI_ID <= 0)
{
return null;
}
return kpisCache.getOrLoad(WEBUI_KPI_ID, () -> {
final I_WEBUI_KPI kpiDef = InterfaceWrapperHelper.create(Env.getCtx(), WEBUI_KPI_ID, I_WEBUI_KPI.class, ITrx.TRXNAME_None);
if (kpiDef == null)
{
return null;
}
return createKPI(kpiDef);
});
}
示例3: retrieveKPIFields
import org.compiere.util.Env; //导入依赖的package包/类
private List<KPIField> retrieveKPIFields(final int WEBUI_KPI_ID, final boolean isComputeOffset)
{
return queryBL.createQueryBuilder(I_WEBUI_KPI_Field.class, Env.getCtx(), ITrx.TRXNAME_None)
.addEqualsFilter(I_WEBUI_KPI_Field.COLUMN_WEBUI_KPI_ID, WEBUI_KPI_ID)
.addOnlyActiveRecordsFilter()
//
.orderBy()
// TODO: add SeqNo
.addColumn(I_WEBUI_KPI_Field.COLUMN_WEBUI_KPI_Field_ID)
.endOrderBy()
//
.create()
.stream(I_WEBUI_KPI_Field.class)
.map(kpiField -> createKPIField(kpiField, isComputeOffset))
.collect(GuavaCollectors.toImmutableList());
}
示例4: uploadImage
import org.compiere.util.Env; //导入依赖的package包/类
@PostMapping
public int uploadImage(@RequestParam("file") final MultipartFile file) throws IOException
{
userSession.assertLoggedIn();
final String name = file.getOriginalFilename();
final byte[] data = file.getBytes();
final String contentType = file.getContentType();
final String filenameNorm = normalizeUploadFilename(name, contentType);
final MImage adImage = new MImage(Env.getCtx(), 0, ITrx.TRXNAME_None);
adImage.setName(filenameNorm);
adImage.setBinaryData(data);
// TODO: introduce adImage.setTemporary(true);
InterfaceWrapperHelper.save(adImage);
return adImage.getAD_Image_ID();
}
示例5: getWebuiImage
import org.compiere.util.Env; //导入依赖的package包/类
private WebuiImage getWebuiImage(final int imageId, final int maxWidth, final int maxHeight)
{
if (imageId <= 0)
{
throw new IllegalArgumentException("Invalid image id");
}
final MImage adImage = MImage.get(Env.getCtx(), imageId);
if (adImage == null || adImage.getAD_Image_ID() <= 0)
{
throw new EntityNotFoundException("Image id not found: " + imageId);
}
final boolean hasAccess = userSession.getUserRolePermissions().canView(adImage.getAD_Client_ID(), adImage.getAD_Org_ID(), I_AD_Image.Table_ID, adImage.getAD_Image_ID());
if (!hasAccess)
{
throw new EntityNotFoundException("Image id not found: " + imageId);
}
return WebuiImage.of(adImage, maxWidth, maxHeight);
}
示例6: verifyLanguageAndSet
import org.compiere.util.Env; //导入依赖的package包/类
/**
* @param lang
* @return previous language
*/
String verifyLanguageAndSet(final Language lang)
{
final Properties ctx = getCtx();
final String adLanguageOld = Env.getContext(ctx, Env.CTXNAME_AD_Language);
//
// Check the language (and update it if needed)
Env.verifyLanguage(lang);
//
// Actual update
final String adLanguageNew = lang.getAD_Language();
Env.setContext(ctx, Env.CTXNAME_AD_Language, adLanguageNew);
this.locale = lang.getLocale();
UserSession.logger.info("Changed AD_Language: {} -> {}, {}", adLanguageOld, adLanguageNew, lang);
return adLanguageOld;
}
示例7: applyTemplate
import org.compiere.util.Env; //导入依赖的package包/类
private void applyTemplate(final WebuiLetter letter, final WebuiLetterBuilder newLetterBuilder, final LookupValue templateLookupValue)
{
final Properties ctx = Env.getCtx();
final int textTemplateId = templateLookupValue.getIdAsInt();
final MADBoilerPlate boilerPlate = MADBoilerPlate.get(ctx, textTemplateId);
//
// Attributes
final BoilerPlateContext context = documentCollection.createBoilerPlateContext(letter.getContextDocumentPath());
//
// Content and subject
newLetterBuilder.textTemplateId(textTemplateId);
newLetterBuilder.content(boilerPlate.getTextSnippetParsed(context));
newLetterBuilder.subject(boilerPlate.getSubject());
}
示例8: applyTemplate
import org.compiere.util.Env; //导入依赖的package包/类
private void applyTemplate(final WebuiEmail email, final WebuiEmailBuilder newEmailBuilder, final LookupValue templateId)
{
final Properties ctx = Env.getCtx();
final MADBoilerPlate boilerPlate = MADBoilerPlate.get(ctx, templateId.getIdAsInt());
//
// Attributes
final BoilerPlateContext attributes = documentCollection.createBoilerPlateContext(email.getContextDocumentPath());
//
// Subject
final String subject = MADBoilerPlate.parseText(ctx, boilerPlate.getSubject(), true, attributes, ITrx.TRXNAME_None);
newEmailBuilder.subject(subject);
// Message
newEmailBuilder.message(boilerPlate.getTextSnippetParsed(attributes));
}
示例9: moveTUToLU
import org.compiere.util.Env; //导入依赖的package包/类
private void moveTUToLU(final int tuId, final HUEditorRow luRow)
{
final I_M_HU newTU = create(Env.getCtx(), tuId, I_M_HU.class, ITrx.TRXNAME_ThreadInherited);
final WebuiHUTransformParameters tuToLUParameters = WebuiHUTransformParameters.builder()
.actionType(ActionType.TU_To_ExistingLU)
.qtyTU(BigDecimal.ONE)
.tuHU(newTU)
.luHU(luRow.getM_HU())
.build();
final HUEditorRowId newTURowId = HUEditorRowId.ofHU(tuId, -1);
final HUEditorRow newTURow = getView().getById(newTURowId.toDocumentId());
final WebuiHUTransformCommand tuToLUcommand = WebuiHUTransformCommand.builder()
.selectedRow(newTURow)
.parameters(tuToLUParameters)
.build();
Services.get(ITrxManager.class).call(() -> tuToLUcommand.execute());
getView().invalidateAll();
}
示例10: createNewCU
import org.compiere.util.Env; //导入依赖的package包/类
private I_M_HU createNewCU(final HUEditorRow cuRowToUse, final WebuiHUTransformParameters parameters)
{
final WebuiHUTransformCommand command = WebuiHUTransformCommand.builder()
.selectedRow(cuRowToUse)
.parameters(parameters)
.build();
final WebuiHUTransformCommandResult resultValue = Services.get(ITrxManager.class).call(() -> command.execute());
final ImmutableSet<Integer> huIdsToAddToView = resultValue.getHuIdsCreated();
Check.assume(huIdsToAddToView.size() <= 1, "Only one or no CU should be created");
if (Check.isEmpty(huIdsToAddToView))
{
return cuRowToUse.getM_HU();
}
final int huId = huIdsToAddToView.asList().get(0);
final I_M_HU cu = create(Env.getCtx(), huId, I_M_HU.class, ITrx.TRXNAME_ThreadInherited);
return cu;
}
示例11: doIt
import org.compiere.util.Env; //导入依赖的package包/类
@Override
protected String doIt() throws Exception
{
final List<I_M_HU> husToDestroy = streamSelectedHUs(Select.ONLY_TOPLEVEL).collect(ImmutableList.toImmutableList());
if (husToDestroy.isEmpty())
{
throw new AdempiereException("@[email protected]");
}
final Timestamp movementDate = Env.getDate(getCtx());
huInventoryBL.moveToGarbage(husToDestroy, movementDate);
huIdsDestroyed = husToDestroy.stream().map(I_M_HU::getM_HU_ID).collect(ImmutableSet.toImmutableSet());
return MSG_OK;
}
示例12: createRowAttributes
import org.compiere.util.Env; //导入依赖的package包/类
private HUEditorRowAttributes createRowAttributes(final ViewRowAttributesKey key)
{
final int huId = key.getHuId().toInt();
final I_M_HU hu = InterfaceWrapperHelper.create(Env.getCtx(), huId, I_M_HU.class, ITrx.TRXNAME_None);
if (hu == null)
{
throw new IllegalArgumentException("No HU found for M_HU_ID=" + huId);
}
final IAttributeStorage attributesStorage = getAttributeStorageFactory().getAttributeStorage(hu);
attributesStorage.setSaveOnChange(true);
final DocumentId documentTypeId = DocumentId.of(huId);
final DocumentId huEditorRowId = key.getHuEditorRowId();
final DocumentPath documentPath = DocumentPath.rootDocumentPath(DocumentType.ViewRecordAttributes, documentTypeId, huEditorRowId);
final boolean rowAttributesReadonly = isReadonly() // readonly if the provider shall provide readonly attributes
|| !X_M_HU.HUSTATUS_Planning.equals(hu.getHUStatus()); // or, readonly if not Planning, see https://github.com/metasfresh/metasfresh-webui-api/issues/314
return new HUEditorRowAttributes(documentPath, attributesStorage, rowAttributesReadonly);
}
示例13: retrieveHUPIItemProductRecords
import org.compiere.util.Env; //导入依赖的package包/类
public List<I_M_HU_PI_Item_Product> retrieveHUPIItemProductRecords(
@NonNull final Properties ctx,
@NonNull final I_M_Product product,
@Nullable final I_C_BPartner bPartner,
final boolean includeVirtualItem)
{
final IHUPIItemProductDAO hupiItemProductDAO = Services.get(IHUPIItemProductDAO.class);
final ISysConfigBL sysConfigBL = Services.get(ISysConfigBL.class);
final boolean allowInfiniteCapacity = sysConfigBL.getBooleanValue(SYSCONFIG_ALLOW_INFINIT_CAPACITY_TUS, true,
Env.getAD_Client_ID(ctx), Env.getAD_Org_ID(ctx));
final List<I_M_HU_PI_Item_Product> list = hupiItemProductDAO
.retrieveTUs(ctx, product, bPartner, allowInfiniteCapacity);
if (includeVirtualItem)
{
list.add(hupiItemProductDAO.retrieveVirtualPIMaterialItemProduct(ctx));
}
return list;
}
示例14: getCtx
import org.compiere.util.Env; //导入依赖的package包/类
@Override
public Properties getCtx(final Object model, final boolean useClientOrgFromModel)
{
final Document document = DocumentInterfaceWrapper.getDocument(model);
if (document != null)
{
return document.getCtx();
}
// Notify developer that (s)he is using wrong models
if (Services.get(IDeveloperModeBL.class).isEnabled())
{
final AdempiereException e = new AdempiereException("Cannot get context from model " + model + " because is not supported. Returning global context.");
logger.warn(e.getLocalizedMessage(), e);
}
return Env.getCtx(); // fallback to global context
}
示例15: duplicateDocumentInTrx
import org.compiere.util.Env; //导入依赖的package包/类
private DocumentPath duplicateDocumentInTrx(final DocumentPath fromDocumentPath)
{
// NOTE: assume it's already running in transaction
final TableRecordReference fromRecordRef = getTableRecordReference(fromDocumentPath);
final Object fromModel = fromRecordRef.getModel(PlainContextAware.newWithThreadInheritedTrx());
final String tableName = InterfaceWrapperHelper.getModelTableName(fromModel);
final PO fromPO = InterfaceWrapperHelper.getPO(fromModel);
final PO toPO = TableModelLoader.instance.newPO(Env.getCtx(), tableName, ITrx.TRXNAME_ThreadInherited);
toPO.setDynAttribute(PO.DYNATTR_CopyRecordSupport, CopyRecordFactory.getCopyRecordSupport(tableName)); // set "getValueToCopy" advisor
PO.copyValues(fromPO, toPO, true);
InterfaceWrapperHelper.save(toPO);
final CopyRecordSupport childCRS = CopyRecordFactory.getCopyRecordSupport(tableName);
childCRS.setAD_Window_ID(fromDocumentPath.getAD_Window_ID(-1));
childCRS.setParentPO(toPO);
childCRS.setBase(true);
childCRS.copyRecord(fromPO, ITrx.TRXNAME_ThreadInherited);
final DocumentPath toDocumentPath = DocumentPath.rootDocumentPath(fromDocumentPath.getWindowId(), DocumentId.of(toPO.get_ID()));
return toDocumentPath;
}