本文整理汇总了Java中org.compiere.util.Env.getCtx方法的典型用法代码示例。如果您正苦于以下问题:Java Env.getCtx方法的具体用法?Java Env.getCtx怎么用?Java Env.getCtx使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.compiere.util.Env
的用法示例。
在下文中一共展示了Env.getCtx方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
示例2: 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());
}
示例3: 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));
}
示例4: 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
}
示例5: getAvailableDocActions
import org.compiere.util.Env; //导入方法依赖的package包/类
private final Set<String> getAvailableDocActions(final IValidationContext evalCtx)
{
final Properties ctx = Env.getCtx();
final IDocActionOptionsContext optionsCtx = DefaultDocActionOptionsContext.builder(ctx)
.setTableName(extractContextTableName(evalCtx))
.setDocStatus(extractDocStatus(evalCtx))
.setC_DocType_ID(extractC_DocType_ID(evalCtx))
.setProcessing(extractProcessing(evalCtx))
.setOrderType(extractOrderType(evalCtx))
.setIsSOTrx(extractIsSOTrx(evalCtx))
.build();
Services.get(IDocActionOptionsBL.class).updateDocActions(optionsCtx);
final Set<String> availableDocActions = optionsCtx.getDocActions();
return availableDocActions;
}
示例6: buildMsg
import org.compiere.util.Env; //导入方法依赖的package包/类
private static String buildMsg(int orgId, String additionalMessage)
{
final Properties ctx = Env.getCtx();
final StringBuffer sb = new StringBuffer();
sb.append(Msg.getMsg(ctx, MSG));
if (!Util.isEmpty(additionalMessage, true))
{
sb.append(" - ").append(additionalMessage);
}
if (orgId > 0)
{
String orgName = getOrgName(orgId);
sb.append("(").append(Msg.translate(ctx, "AD_Org_ID")).append(": ").append(orgName).append(")");
}
return sb.toString();
}
示例7: assertSysConfig
import org.compiere.util.Env; //导入方法依赖的package包/类
public static void assertSysConfig(
final int clientId, final int orgId,
final String name, final String expectedValue)
{
final Properties ctx = Env.getCtx();
final String value = MSysConfig.getValue(name, "", clientId, orgId);
if (orgId > 0)
{
// make sure that clientId and orgId are consistent
final MOrg org = MOrg.get(ctx, orgId);
assertEquals("AD_Client_ID of given Org '" + org.getName() + "' is different from given client ID", clientId, org.getAD_Client_ID());
// now make the actual check
assertEquals("Expected " + name + " to be set correctly for Org '" + org.getName() + "'", expectedValue, value);
}
else
{
// basically the same check, but a different error message if ordIg=0
assertEquals("Expected " + name + " to be set correctly for Client '" + MClient.get(ctx, clientId).getName() + "'", expectedValue, value);
}
}
示例8: isAvailable
import org.compiere.util.Env; //导入方法依赖的package包/类
@Override
public boolean isAvailable()
{
final Properties ctx = Env.getCtx();
final VEditor editor = getEditor();
final GridField gridField = editor.getField();
// only system admins can change lists, so no need to zoom for others
final int roleId = Env.getAD_Role_ID(ctx);
if (gridField.getDisplayType() == DisplayType.List && roleId != 0)
{
return false;
}
if (editor instanceof IZoomableEditor)
{
return true;
}
if (!gridField.isLookup())
{
return false;
}
return true;
}
示例9: retrieveOrgInfo
import org.compiere.util.Env; //导入方法依赖的package包/类
public I_AD_OrgInfo retrieveOrgInfo(final int orgId, final String trxName) {
final PreparedStatement pstmt = DB.prepareStatement(SQL_ORGINFO,
trxName);
ResultSet rs = null;
try {
pstmt.setInt(1, orgId);
rs = pstmt.executeQuery();
if (rs.next()) {
return new MOrgInfo(Env.getCtx(), rs, trxName);
}
return null;
} catch (SQLException e) {
throw new RuntimeException(e);
} finally {
DB.close(rs, pstmt);
}
}
示例10: getCtx
import org.compiere.util.Env; //导入方法依赖的package包/类
/**
* Get context from model and setting in context AD_Client_ID and AD_Org_ID according to the model if useClientOrgFromModel is true
*
* @param model
* @param useClientOrgFromModel
* @return
*/
public static Properties getCtx(final Object model, final boolean useClientOrgFromModel)
{
if (model == null)
{
return Env.getCtx();
}
else if (model instanceof IContextAware)
{
return ((IContextAware)model).getCtx();
}
else if (model instanceof Properties)
{
return (Properties)model; // this *is* already the ctx
}
else
{
return helpers.getCtx(model, useClientOrgFromModel);
}
}
示例11: newInstanceFromCurrentContext
import org.compiere.util.Env; //导入方法依赖的package包/类
public static final ViewEvaluationCtx newInstanceFromCurrentContext()
{
final Properties ctx = Env.getCtx();
final String adLanguage = Env.getAD_Language(ctx);
final UserRolePermissionsKey permissionsKey = UserRolePermissionsKey.of(ctx);
return new ViewEvaluationCtx(adLanguage, permissionsKey);
}
示例12: createNewLetter
import org.compiere.util.Env; //导入方法依赖的package包/类
@PostMapping
@ApiOperation("Creates a new letter")
public JSONLetter createNewLetter(@RequestBody final JSONLetterRequest request)
{
userSession.assertLoggedIn();
final DocumentPath contextDocumentPath = JSONDocumentPath.toDocumentPathOrNull(request.getDocumentPath());
//
// Extract context BPartner, Location and Contact
final BoilerPlateContext context = documentCollection.createBoilerPlateContext(contextDocumentPath);
final int bpartnerId = context.getC_BPartner_ID(-1);
final int bpartnerLocationId = context.getC_BPartner_Location_ID(-1);
final int contactId = context.getAD_User_ID(-1);
//
// Build BPartnerAddress
final PlainDocumentLocation documentLocation = new PlainDocumentLocation(Env.getCtx(), bpartnerId, bpartnerLocationId, contactId, ITrx.TRXNAME_None);
Services.get(IDocumentLocationBL.class).setBPartnerAddress(documentLocation);
final String bpartnerAddress = documentLocation.getBPartnerAddress();
final WebuiLetter letter = lettersRepo.createNewLetter(WebuiLetter.builder()
.contextDocumentPath(contextDocumentPath)
.ownerUserId(userSession.getAD_User_ID())
.adOrgId(context.getAD_Org_ID(userSession.getAD_Org_ID()))
.bpartnerId(bpartnerId)
.bpartnerLocationId(bpartnerLocationId)
.bpartnerAddress(bpartnerAddress)
.bpartnerContactId(contactId));
return JSONLetter.of(letter);
}
示例13: checkPreconditionsApplicable
import org.compiere.util.Env; //导入方法依赖的package包/类
@Override
public ProcessPreconditionsResolution checkPreconditionsApplicable()
{
if(!isHUEditorView())
{
return ProcessPreconditionsResolution.rejectWithInternalReason("not the HU view");
}
final HUReportService huReportService = HUReportService.get();
final Properties ctx = Env.getCtx(); // note: at this point, the JavaProces's ctx was not set so we are using the global context
final int adProcessId = huReportService.retrievePrintReceiptLabelProcessId(ctx);
if (adProcessId <= 0)
{
return ProcessPreconditionsResolution.reject("Receipt label process not configured via sysconfig " + HUReportService.SYSCONFIG_RECEIPT_LABEL_PROCESS_ID);
}
if (!getSelectedRowIds().isSingleDocumentId())
{
return ProcessPreconditionsResolution.reject("No (single) row selected");
}
final I_M_HU hu = getSingleSelectedRow().getM_HU();
if (hu == null)
{
return ProcessPreconditionsResolution.reject("No (single) HU selected");
}
final List<I_M_HU> husToProcess = huReportService.getHUsToProcess(hu, adProcessId);
if (husToProcess.isEmpty())
{
return ProcessPreconditionsResolution.reject("current HU's type does not match the receipt label process");
}
return ProcessPreconditionsResolution.accept();
}
示例14: SqlDocumentQueryBuilder
import org.compiere.util.Env; //导入方法依赖的package包/类
private SqlDocumentQueryBuilder(final DocumentEntityDescriptor entityDescriptor)
{
ctx = Env.getCtx();
Check.assumeNotNull(entityDescriptor, "Parameter entityDescriptor is not null");
entityBinding = SqlDocumentEntityDataBindingDescriptor.cast(entityDescriptor.getDataBinding());
}
示例15: build
import org.compiere.util.Env; //导入方法依赖的package包/类
public LookupDataSourceContext build()
{
//
// Pre-build preparations
{
//
// Standard values, needed by each query
final Properties ctx = Env.getCtx();
final String adLanguage = Env.getAD_Language(ctx);
final String permissionsKey = UserRolePermissionsKey.toPermissionsKeyString(ctx);
putValue(PARAM_AD_Language, adLanguage);
putValue(PARAM_UserRolePermissionsKey, permissionsKey);
}
//
// Collect all values required for given query
// failIfNotFound=true
collectContextValues(getRequiredParameters(), true);
//
// Collect all values required by the post-query predicate
// failIfNotFound=false because it might be that NOT all postQueryPredicate's parameters are mandatory!
collectContextValues(CtxNames.parseAll(postQueryPredicate.getParameters()), false);
//
// Build the effective context
return new LookupDataSourceContext(lookupTableName, valuesCollected, idToFilter, postQueryPredicate);
}