當前位置: 首頁>>代碼示例>>Java>>正文


Java Env類代碼示例

本文整理匯總了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;
}
 
開發者ID:metasfresh,項目名稱:metasfresh-webui-api,代碼行數:21,代碼來源:UserDashboardRepository.java

示例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);
	});
}
 
開發者ID:metasfresh,項目名稱:metasfresh-webui-api,代碼行數:17,代碼來源:KPIRepository.java

示例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());
}
 
開發者ID:metasfresh,項目名稱:metasfresh-webui-api,代碼行數:17,代碼來源:KPIRepository.java

示例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();
}
 
開發者ID:metasfresh,項目名稱:metasfresh-webui-api,代碼行數:19,代碼來源:ImageRestController.java

示例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);
}
 
開發者ID:metasfresh,項目名稱:metasfresh-webui-api,代碼行數:22,代碼來源:ImageRestController.java

示例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;
}
 
開發者ID:metasfresh,項目名稱:metasfresh-webui-api,代碼行數:23,代碼來源:InternalUserSessionData.java

示例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());
}
 
開發者ID:metasfresh,項目名稱:metasfresh-webui-api,代碼行數:17,代碼來源:LetterRestController.java

示例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));
}
 
開發者ID:metasfresh,項目名稱:metasfresh-webui-api,代碼行數:18,代碼來源:MailRestController.java

示例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();

}
 
開發者ID:metasfresh,項目名稱:metasfresh-webui-api,代碼行數:27,代碼來源:WEBUI_Add_Batch_SerialNo_To_CUs.java

示例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;
}
 
開發者ID:metasfresh,項目名稱:metasfresh-webui-api,代碼行數:24,代碼來源:WEBUI_Add_Batch_SerialNo_To_CUs.java

示例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;
}
 
開發者ID:metasfresh,項目名稱:metasfresh-webui-api,代碼行數:17,代碼來源:WEBUI_M_HU_MoveToGarbage.java

示例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);
}
 
開發者ID:metasfresh,項目名稱:metasfresh-webui-api,代碼行數:22,代碼來源:HUEditorRowAttributesProvider.java

示例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;
}
 
開發者ID:metasfresh,項目名稱:metasfresh-webui-api,代碼行數:22,代碼來源:WEBUI_ProcessHelper.java

示例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
}
 
開發者ID:metasfresh,項目名稱:metasfresh-webui-api,代碼行數:19,代碼來源:DocumentInterfaceWrapperHelper.java

示例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;
}
 
開發者ID:metasfresh,項目名稱:metasfresh-webui-api,代碼行數:25,代碼來源:DocumentCollection.java


注:本文中的org.compiere.util.Env類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。