当前位置: 首页>>代码示例>>Java>>正文


Java Env.deriveCtx方法代码示例

本文整理汇总了Java中org.compiere.util.Env.deriveCtx方法的典型用法代码示例。如果您正苦于以下问题:Java Env.deriveCtx方法的具体用法?Java Env.deriveCtx怎么用?Java Env.deriveCtx使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.compiere.util.Env的用法示例。


在下文中一共展示了Env.deriveCtx方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import org.compiere.util.Env; //导入方法依赖的package包/类
@Before
public void init()
{
	AdempiereTestHelper.get().init();
	helper = new HUDocumentSelectTestHelper();

	// note that the helper's constructor also sets up the ctx
	context = new PlainContextAware(Env.getCtx(), ITrx.TRXNAME_None);

	// register this listener to make sure that when the HUs are assigned, then also the ATTR_ReceiptInOutLine_ID HU-Attribute is set
	Services.get(IHUAssignmentBL.class).registerHUAssignmentListener(ReceiptInOutLineHUAssignmentListener.instance);

	//
	// Create an AD_SysConfig for SaveDecoupledHUAttributesDAO.SYSCONFIG_AutoFlushEnabledInitial, to make sure that the HU_Attributes that are set by the ReceiptInOutLineHUAssignmentListener are actually stored.
	final Properties deriveCtx = Env.deriveCtx(context.getCtx());
	Env.setContext(deriveCtx, Env.CTXNAME_AD_Client_ID, 0);
	Env.setContext(deriveCtx, Env.CTXNAME_AD_Org_ID, 0);
	final I_AD_SysConfig sysConfig = InterfaceWrapperHelper.newInstance(I_AD_SysConfig.class, new PlainContextAware(deriveCtx, ITrx.TRXNAME_None));
	sysConfig.setName(SaveDecoupledHUAttributesDAO.SYSCONFIG_AutoFlushEnabledInitial);
	sysConfig.setValue("Y");
	InterfaceWrapperHelper.save(sysConfig);
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:23,代码来源:PPOrderMInOutLineRetrievalServiceTest.java

示例2: ProcessParameterPanelModel

import org.compiere.util.Env; //导入方法依赖的package包/类
/**
 * Dynamic generated Parameter panel.
 *
 * @param parentCtx parent context
 * @param pi process info, used ONLY to get AD_Process_ID, WindowNo and TabNo; no reference is stored to it
 */
public ProcessParameterPanelModel(final Properties parentCtx, final ProcessInfo pi)
{
	super();
	Check.assumeNotNull(pi, "pi not null");

	// NOTE: we are using same WindowNo/TabNo as the calling window/tab but we will create a shadow context just to not alter the current context
	ctx = Env.deriveCtx(parentCtx);
	windowNo = pi.getWindowNo();
	tabNo = pi.getTabNo();
	processId = pi.getAD_Process_ID();

	defaultParametersUpdater = ProcessDefaultParametersUpdater.newInstance()
			.addDefaultParametersProvider(pi)
			.addDefaultParametersProvider(parameter -> GridField.extractFrom(parameter).getDefault())
			.onDefaultValue((parameter, value) -> setFieldValue(GridField.extractFrom(parameter), value));

	processClassInfo = pi.getProcessClassInfo();

	createFields();
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:27,代码来源:ProcessParameterPanelModel.java

示例3: test_setReplicationCtx

import org.compiere.util.Env; //导入方法依赖的package包/类
@Test
public void test_setReplicationCtx() throws Exception
{
	final Properties initialCtx = Env.newTemporaryCtx();
	Env.setContext(initialCtx, Env.CTXNAME_AD_Client_ID, 12345);

	final Properties ctx = Env.deriveCtx(initialCtx);
	Assert.assertEquals(Env.getContextAsInt(ctx, Env.CTXNAME_AD_Client_ID), 12345);

	setReplicationCtx(ctx, Env.CTXNAME_AD_Client_ID, 1, false); // overwrite = false
	Assert.assertEquals(Env.getContextAsInt(ctx, Env.CTXNAME_AD_Client_ID), 1);

	setReplicationCtx(ctx, Env.CTXNAME_AD_Client_ID, 1, true); // overwrite = true, but same value
	Assert.assertEquals(Env.getContextAsInt(ctx, Env.CTXNAME_AD_Client_ID), 1);

	// Test remove
	// We expect that AD_Client_ID to be set to ZERO
	setReplicationCtx(ctx, Env.CTXNAME_AD_Client_ID, null, true); // overwrite = true
	Assert.assertEquals(Env.getContextAsInt(ctx, Env.CTXNAME_AD_Client_ID), 0);
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:21,代码来源:ImportHelperTest.java

示例4: MSetup

import org.compiere.util.Env; //导入方法依赖的package包/类
/**
 *  Constructor
 *  @param ctx context
 *  @param WindowNo window
 */
public MSetup(Properties ctx, int WindowNo)
{
	m_ctx = Env.deriveCtx(ctx);	//	copy
	m_lang = Env.getAD_Language(m_ctx);
	m_WindowNo = WindowNo;
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:12,代码来源:MSetup.java

示例5: createContext

import org.compiere.util.Env; //导入方法依赖的package包/类
private final Properties createContext(final Properties ctx, final PrintInfo info, final String trxName)
{
	final int adTableId = info.getAD_Table_ID();

	if (adTableId <= 0)
	{
		return ctx;
	}

	final int recordId = info.getRecord_ID();
	if (recordId <= 0)
	{
		return ctx;
	}

	final String tableName = Services.get(IADTableDAO.class).retrieveTableName(adTableId);
	final IClientOrgAware record = InterfaceWrapperHelper.create(ctx, tableName, recordId, IClientOrgAware.class, trxName);
	if (record == null)
	{
		// attached record was not found. return the initial context (an error was already logged by loader)
		return ctx;
	}
	final Properties ctxToUse = Env.deriveCtx(ctx);
	Env.setContext(ctxToUse, Env.CTXNAME_AD_Client_ID, record.getAD_Client_ID());
	Env.setContext(ctxToUse, Env.CTXNAME_AD_Org_ID, record.getAD_Org_ID());
	// setClientOrg(archivedPO);

	return ctxToUse;

}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:31,代码来源:ArchiveBL.java

示例6: setPrintFormat

import org.compiere.util.Env; //导入方法依赖的package包/类
/**************************************************************************
 * Set Print Format
 * Optionally re-calculate layout
 * 
 * @param doLayout if layout exists, redo it
 * @param format print Format
 */
public void setPrintFormat(final MPrintFormat format, final boolean doLayout)
{
	m_format = format;
	// Initial & Default Settings
	m_printCtx = Env.deriveCtx(format.getCtx());

	// Set Paper
	boolean tempHasLayout = m_hasLayout;
	m_hasLayout = false;	// do not start re-calculation
	MPrintPaper mPaper = MPrintPaper.get(format.getAD_PrintPaper_ID());
	if (m_format.isStandardHeaderFooter())
		setPaper(mPaper.getCPaper());
	else
		setPaper(mPaper.getCPaper(),
				m_format.getHeaderMargin(), m_format.getFooterMargin());
	m_hasLayout = tempHasLayout;
	//
	m_printColor = MPrintColor.get(getCtx(), format.getAD_PrintColor_ID());
	m_printFont = MPrintFont.get(format.getAD_PrintFont_ID());

	// Print Context
	Env.setContext(m_printCtx, Page.CONTEXT_REPORTNAME, m_format.getName());
	Env.setContext(m_printCtx, Page.CONTEXT_HEADER, Env.getHeader(m_printCtx, 0));
	Env.setContext(m_printCtx, Env.CTXNAME_AD_Language, m_format.getLanguage().getAD_Language());

	if (m_hasLayout && doLayout)
		layout();			// re-calculate
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:36,代码来源:LayoutEngine.java

示例7: createEvaluationContext

import org.compiere.util.Env; //导入方法依赖的package包/类
@Override
public Evaluatee createEvaluationContext()
{
	final Properties privateCtx = Env.deriveCtx(getCtx());

	final PO po = getPO();
	final POInfo poInfo = po.getPOInfo();
	for (int i = 0; i < poInfo.getColumnCount(); i++)
	{
		final Object val;
		final int dispType = poInfo.getColumnDisplayType(i);
		if (DisplayType.isID(dispType))
		{
			// make sure we get a 0 instead of a null for foreign keys
			val = po.get_ValueAsInt(i);
		}
		else
		{
			val = po.get_Value(i);
		}

		if (val == null)
		{
			continue;
		}

		if (val instanceof Integer)
		{
			Env.setContext(privateCtx, "#" + po.get_ColumnName(i), (Integer)val);
		}
		else if (val instanceof String)
		{
			Env.setContext(privateCtx, "#" + po.get_ColumnName(i), (String)val);
		}
	}

	return Evaluatees.ofCtx(privateCtx, Env.WINDOW_None, false);
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:39,代码来源:ZoomInfoFactory.java

示例8: createContext

import org.compiere.util.Env; //导入方法依赖的package包/类
private final Properties createContext(final Element rootElement)
{
	Check.assumeNotNull(_initialCtx, "initialCtx not null");
	final Properties ctx = Env.deriveCtx(_initialCtx);

	if (rootElement.hasAttribute(RPL_Constants.XML_ATTR_AD_Client_Value))
	{
		final String AD_Client_Value = rootElement.getAttribute(RPL_Constants.XML_ATTR_AD_Client_Value);
		updateContextFromADClientValue(ctx, AD_Client_Value);
	}

	if (rootElement.hasAttribute(RPL_Constants.XML_ATTR_AD_SESSION_ID))
	{
		final int adSessionId = getAttributeAsInt(rootElement, RPL_Constants.XML_ATTR_AD_SESSION_ID);
		updateContextFromSession(ctx, adSessionId);
	}
	else
	{
		// task 08569: is there is no incoming session, then *do not* fall back to the one from '_initialCtx', but make it explicit that there is no session.
		// this XML needs to have a request handler that deals with the situation (e.g. by doing a login)
		setReplicationCtx(ctx, Env.CTXNAME_AD_Session_ID, Env.CTXVALUE_AD_SESSION_ID_NONE, false);
	}

	//
	// Validate context
	if (!Env.containsKey(ctx, Env.CTXNAME_AD_Client_ID))
	{
		throw new ReplicationException(ReplicationHelper.MSG_XMLInvalidContext)
				.setParameter(Env.CTXNAME_AD_Client_ID, null);
	}

	return ctx;
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:34,代码来源:ImportHelper.java

示例9: AdempiereServer

import org.compiere.util.Env; //导入方法依赖的package包/类
/**************************************************************************
 * 	Server Base Class
 * 	@param model model
 *	@param initialNapSecs delay time running in sec
 */
public AdempiereServer (final AdempiereProcessor model, final int initialNapSecs)
{
	super(
			AdempiereServerGroup.get(), // ThreadGroup
			null, // Runnable
			model.getClass().getSimpleName() + "-" + model.getName(), // Thread Name
			0 // stackSize (0=this parameter is to be ignored)
	);
	p_model = model;
	m_ctx = Env.deriveCtx(model.getCtx());
	p_client = Services.get(IClientDAO.class).retriveClient(m_ctx);
	Env.setContext(m_ctx, Env.CTXNAME_AD_Client_ID, p_client.getAD_Client_ID());
	m_initialNapSecs = initialNapSecs;
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:20,代码来源:AdempiereServer.java

示例10: linkReferenceNo

import org.compiere.util.Env; //导入方法依赖的package包/类
@Override
public void linkReferenceNo(final PO po, final IReferenceNoGeneratorInstance instance)
{
	final IReferenceNoDAO dao = Services.get(IReferenceNoDAO.class);

	final Properties localCtx = Env.deriveCtx(po.getCtx());
	Env.setContext(localCtx, "#AD_Client_ID", po.getAD_Client_ID());
	Env.setContext(localCtx, "#AD_Org_ID", po.getAD_Org_ID());

	final String trxName = po.get_TrxName();
	final int tableId = po.get_Table_ID();
	final int recordId = po.get_ID();

	final String referenceNoStr = instance.generateReferenceNo(po);
	if (IReferenceNoGenerator.REFERENCENO_None == referenceNoStr)
	{
		logger.debug("Instance {} did not generate any referenceNo for '{}'. Skip.", new Object[] { instance, po });
		return;
	}

	final I_C_ReferenceNo referenceNo = dao.getCreateReferenceNo(localCtx, instance.getType(), referenceNoStr, trxName);
	dao.getCreateReferenceNoDoc(referenceNo, tableId, recordId);

	
	// 04153 : mark the reference numbers with 'referenceNoStr' created by the system with isManual = N
	if(referenceNo != null)
	{
		referenceNo.setIsManual(false);
		InterfaceWrapperHelper.save(referenceNo); // make sure the flag is saved
	}

	if (logger.isDebugEnabled())
	{
		logger.debug("Created reference " + referenceNoStr + " for " + po);
	}
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:37,代码来源:ReferenceNoBL.java

示例11: createDAOCtx

import org.compiere.util.Env; //导入方法依赖的package包/类
private static final Properties createDAOCtx()
{
	final Properties ctx = Env.deriveCtx(Env.getCtx());
	Env.setContext(ctx, Env.CTXNAME_AD_Client_ID, Env.CTXVALUE_AD_Client_ID_System);
	Env.setContext(ctx, Env.CTXNAME_AD_Org_ID, Env.CTXVALUE_AD_Org_ID_System);
	return ctx;
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:8,代码来源:UserPreference.java

示例12: test_createPrintClientsEntry

import org.compiere.util.Env; //导入方法依赖的package包/类
@Test
public void test_createPrintClientsEntry()
{
	final Properties ctx = Env.deriveCtx(Env.getCtx());
	final int adSessionId = 12345;
	Env.setContext(ctx, Env.CTXNAME_AD_Session_ID, adSessionId);

	final String hostKey = "hostKeyTest01";

	final I_AD_Print_Clients entry1 = Services.get(IPrintClientsBL.class).createPrintClientsEntry(ctx, hostKey);

	Assert.assertNotNull("Printing clients entry shall be created", entry1);
	Assert.assertEquals("Invalid AD_Session_ID", adSessionId, entry1.getAD_Session_ID());
	Assert.assertEquals("Invalid HostKey", hostKey, entry1.getHostKey());
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:16,代码来源:PrintClientsBLTest.java

示例13: test_createPrintClientsEntry_NoDuplicates

import org.compiere.util.Env; //导入方法依赖的package包/类
@Test
public void test_createPrintClientsEntry_NoDuplicates()
{
	final Properties ctx = Env.deriveCtx(Env.getCtx());
	final int adSessionId = 12345;
	Env.setContext(ctx, Env.CTXNAME_AD_Session_ID, adSessionId);

	final String hostKey1 = "hostKeyTest01-01";
	final I_AD_Print_Clients entry1 = Services.get(IPrintClientsBL.class).createPrintClientsEntry(ctx, hostKey1);

	final I_AD_Print_Clients entry2 = Services.get(IPrintClientsBL.class).createPrintClientsEntry(ctx, hostKey1);
	Assert.assertEquals("No duplicate records shall be created for same hostkey",
			entry1.getAD_Print_Clients_ID(), entry2.getAD_Print_Clients_ID());
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:15,代码来源:PrintClientsBLTest.java

示例14: ensureDocTypesExist

import org.compiere.util.Env; //导入方法依赖的package包/类
private void ensureDocTypesExist(final String docSubType)
{
	final IDocTypeDAO docTypeDAO = Services.get(IDocTypeDAO.class);

	final List<I_AD_Org> orgs = new Query(Env.getCtx(), I_AD_Org.Table_Name, I_AD_Org.COLUMNNAME_AD_Org_ID + "!=0", null)
			.setOnlyActiveRecords(true)
			.setOrderBy(I_AD_Org.COLUMNNAME_AD_Org_ID)
			.list(I_AD_Org.class);

	for (final I_AD_Org org : orgs)
	{
		// we need to work with a local ctx that contains the current Org's AD_Client_ID
		// otherwise both the lookup of existing DocTypes and the creation of new doc types
		// (MDocType.setGL_Category_ID() ) will fail.
		final Properties localCtx = Env.deriveCtx(Env.getCtx());
		Env.setContext(localCtx, Env.CTXNAME_AD_Client_ID, org.getAD_Client_ID());
		Env.setContext(localCtx, Env.CTXNAME_AD_Org_ID, org.getAD_Org_ID());

		final org.compiere.model.I_C_DocType existingDocType = docTypeDAO
				.getDocTypeOrNull(DocTypeQuery.builder()
						.docBaseType(I_C_DocType.DocBaseType_CustomerContract)
						.docSubType(docSubType)
						.adClientId(org.getAD_Client_ID())
						.adOrgId(org.getAD_Org_ID())
						.build());
		if (existingDocType != null)
		{
			continue;
		}

		final POInfo docTypePOInfo = POInfo.getPOInfo(I_C_DocType.Table_Name);
		final String name = Services.get(IADReferenceDAO.class).retrieveListNameTrl(docTypePOInfo.getColumnReferenceValueId(docTypePOInfo.getColumnIndex(I_C_DocType.COLUMNNAME_DocSubType)), docSubType)
				+ " (" + org.getValue() + ")";
		docTypeDAO.createDocType(DocTypeCreateRequest.builder()
				.ctx(localCtx)
				.adOrgId(org.getAD_Org_ID())
				.entityType(Contracts_Constants.ENTITY_TYPE)
				.name(name)
				.printName(name)
				.docBaseType(I_C_DocType.DocBaseType_CustomerContract)
				.docSubType(docSubType)
				.isSOTrx(true)
				.newDocNoSequenceStartNo(10000)
				.build());
	}
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:47,代码来源:C_Flatrate_Term.java

示例15: createOrUpdateTableSequence

import org.compiere.util.Env; //导入方法依赖的package包/类
/**
 * Create/Update {@link I_AD_Sequence} for the given {@code tableName}.
 * 
 * @param ctx context
 * @param TableName table name
 * @param trxName transaction
 * @return created/updated sequence; never return null
 */
private final I_AD_Sequence createOrUpdateTableSequence(final Properties ctx, final String tableName, final String trxName)
{
	I_AD_Sequence sequence = sequenceDAO.retrieveTableSequenceOrNull(ctx, tableName, trxName);
	if (sequence == null)
	{
		final Properties ctxSystem = Env.deriveCtx(ctx);
		Env.setContext(ctxSystem, Env.CTXNAME_AD_Client_ID, 0);
		Env.setContext(ctxSystem, Env.CTXNAME_AD_Org_ID, 0);
		final IContextAware contextProvider = PlainContextAware.newWithTrxName(ctxSystem, trxName);

		final I_AD_Sequence sequenceNew = InterfaceWrapperHelper.newInstance(I_AD_Sequence.class, contextProvider, true); // useCLientOrgFromProvider=true
		sequenceNew.setAD_Org_ID(0);
		sequenceNew.setName(tableName);
		sequenceNew.setDescription("Table " + tableName);
		sequenceNew.setIsTableID(true);
		sequenceNew.setIsActive(true);
		sequence = sequenceNew;
	}

	//
	// Correct Sequence Name (if needed)
	if (!tableName.equals(sequence.getName()))
	{
		sequence.setName(tableName);
	}

	//
	// Check ID range (if needed)
	if (isSequenceRangeCheck())
	{
		updateTableCurrentNext(sequence);
	}

	//
	// Save sequence
	InterfaceWrapperHelper.save(sequence);

	//
	// Log
	final SequenceChangeLog changeLog = new SequenceChangeLog(sequence);
	changeLog.setNewValues(sequence);
	log(changeLog);

	return sequence;
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:54,代码来源:TableSequenceChecker.java


注:本文中的org.compiere.util.Env.deriveCtx方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。