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


Java PO.copyValues方法代码示例

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


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

示例1: duplicateDocumentInTrx

import org.compiere.model.PO; //导入方法依赖的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

示例2: copyValues

import org.compiere.model.PO; //导入方法依赖的package包/类
public static void copyValues(final Object from, final Object to, final boolean honorIsCalculated)
{
	if (POWrapper.isHandled(to))
	{
		final PO fromPO = getPO(from);
		final PO toPO = getPO(to);
		PO.copyValues(fromPO, toPO, honorIsCalculated);
	}
	else if (POJOWrapper.isHandled(from) && POJOWrapper.isHandled(to))
	{
		// NOTE: commented out because some tests are failing because of this
		// Check.assume(!honorIsCalculated, "honorIsCalculated=true not supported by {}", POJOWrapper.class);

		final POJOWrapper fromWrapper = POJOWrapper.getWrapper(from);
		final POJOWrapper toWrapper = POJOWrapper.getWrapper(to);
		toWrapper.copyFrom(fromWrapper);
	}
	else
	{
		throw new AdempiereException("Unsupported models: from=" + from + ", to=" + to);
	}
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:23,代码来源:InterfaceWrapperHelper.java

示例3: copyValues

import org.compiere.model.PO; //导入方法依赖的package包/类
private void copyValues(PO from, PO to)
{
	PO.copyValues(from, to);
	to.setIsActive(from.isActive());
	final POInfo poInfo = POInfo.getPOInfo(to.getCtx(), to.get_Table_ID(), to.get_TrxName());
	final String tableName = poInfo.getTableName();
	for (int i = 0 ; i < poInfo.getColumnCount(); i++)
	{
		final String columnName = poInfo.getColumnName(i);
		if (to.is_new() && isIgnoreColumn(tableName, columnName))
		{
			Object valueOld = to.get_ValueOld(i);
			to.set_ValueNoCheck(columnName, valueOld);
			continue;
		}

		String baseTableName = getColumnBaseTableName(poInfo, i);
		if (baseTableName == null)
			continue;

		int idOld = to.get_ValueAsInt(i);
		if (idsMap.hasNewId(baseTableName, idOld))
		{
			int idNew = idsMap.getNewId(baseTableName, idOld);
			to.set_ValueNoCheck(to.get_ColumnName(i), idNew);
		}
	}
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:29,代码来源:AD_Window_Sync.java

示例4: copyRecord

import org.compiere.model.PO; //导入方法依赖的package包/类
@Override
public void copyRecord(final PO po, final String trxName)
{
	final PO fromPO;
	if (getFromPO_ID() > 0)
	{
		fromPO = TableModelLoader.instance.getPO(getCtx(), po.get_TableName(), getFromPO_ID(), trxName);
	}
	else
	{
		fromPO = po;
	}

	//
	// Copy this level
	setBase(true);
	final PO toPO;
	if (getParentKeyColumn() != null && getParentID() > 0)
	{
		toPO = TableModelLoader.instance.newPO(getCtx(), fromPO.get_TableName(), trxName);
		toPO.setDynAttribute(PO.DYNATTR_CopyRecordSupport, this); // need this for getting defaultValues at copy in PO
		PO.copyValues(fromPO, toPO, true);
		// reset for avoiding copy same object twice
		toPO.setDynAttribute(PO.DYNATTR_CopyRecordSupport, null);
		setBase(false);

		// Parent link:
		toPO.set_CustomColumn(getParentKeyColumn(), getParentID());

		// needs refresh
		// not sure if this is still needed
		for (final String columnName : toPO.get_KeyColumns())
		{
			toPO.set_CustomColumn(columnName, toPO.get_Value(columnName));
		}

		// needs to set IsActive because is not copied
		if (toPO.get_ColumnIndex(COLUMNNAME_IsActive) >= 0)
		{
			toPO.set_CustomColumn(COLUMNNAME_IsActive, fromPO.get_Value(COLUMNNAME_IsActive));
		}

		// Make sure the columns which are required to be unique they have unique values.
		updateSpecialColumnsName(toPO);

		// Notify listeners
		fireOnRecordCopied(toPO, fromPO);

		//
		toPO.setDynAttribute(PO.DYNATTR_CopyRecordSupport_OldValue, fromPO.get_ID()); // need this for changelog
		toPO.saveEx(trxName);
		// setParentPO(toPO); // TODO: remove it, not needed
	}
	else
	{
		toPO = getParentPO();
	}

	//
	// Copy children
	for (final TableInfoVO childTableInfo : getSuggestedChildren(fromPO, getSuggestedChildrenToCopy()))
	{
		for (final Iterator<? extends PO> it = retrieveChildPOsForParent(childTableInfo.getTableName(), fromPO); it.hasNext();)
		{
			final PO childPO = it.next();

			final CopyRecordSupport childCRS = CopyRecordFactory.getCopyRecordSupport(childTableInfo.getTableName());
			childCRS.setParentKeyColumn(childTableInfo.getLinkColumnName());
			childCRS.setAD_Window_ID(getAD_Window_ID());
			childCRS.setParentPO(toPO);

			childCRS.copyRecord(childPO, trxName);
			log.info("Copied {}", childPO);
		}
	}
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:77,代码来源:GeneralCopyRecordSupport.java

示例5: copyValues

import org.compiere.model.PO; //导入方法依赖的package包/类
@Override
public void copyValues(final Object poFrom, final Object poTo)
{
	PO.copyValues(MiscUtils.asPO(poFrom), MiscUtils.asPO(poTo));
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:6,代码来源:POService.java

示例6: doIt

import org.compiere.model.PO; //导入方法依赖的package包/类
@Override
protected String doIt() throws Exception
{


	final I_C_Order newOrder = InterfaceWrapperHelper.create(getCtx(), I_C_Order.class, get_TrxName());
	final PO to = InterfaceWrapperHelper.getPO(newOrder);
	PO.copyValues(sourceOrder, to, true);
	
	orderBL.setDocTypeTargetIdAndUpdateDescription(newOrder, newOrderDocTypeId);
	newOrder.setC_DocType_ID(newOrderDocTypeId);
	
	if (newOrderDateOrdered != null)
	{
		newOrder.setDateOrdered(newOrderDateOrdered);
	}
	if (poReference != null)
	{
		newOrder.setPOReference(poReference);
	}
	
	newOrder.setRef_Proposal(sourceOrder);
	
	InterfaceWrapperHelper.save(newOrder);
	
	final CopyRecordSupport childCRS = CopyRecordFactory.getCopyRecordSupport(I_C_Order.Table_Name);
	childCRS.setParentPO(to);
	childCRS.setBase(true);
	childCRS.copyRecord(sourceOrder, get_TrxName());

	
	newOrder.setDocStatus(X_C_Order.DOCSTATUS_Drafted);
	newOrder.setDocAction(X_C_Order.DOCACTION_Complete);
	InterfaceWrapperHelper.save(newOrder);

	String docAction;
	if (newOrderClompleteIt)
	{
		docAction = IDocument.ACTION_Complete;
		Services.get(IDocumentBL.class).processEx(newOrder, IDocument.ACTION_Complete, IDocument.STATUS_Completed);
	}
	else
	{
		docAction = IDocument.ACTION_Prepare;
	}

	newOrder.setDocAction(docAction);

	
	InterfaceWrapperHelper.save(newOrder);
	
	
	sourceOrder.setRef_Order_ID(newOrder.getC_Order_ID());
	InterfaceWrapperHelper.save(sourceOrder, get_TrxName());

	return newOrder.getDocumentNo();
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:58,代码来源:OrderCreateNewFromProposal.java

示例7: copy

import org.compiere.model.PO; //导入方法依赖的package包/类
/**************************************************************************
 * Copy Constructor
 * 
 * @param ctx context
 * @param AD_Client_ID parent
 * @param AD_Org_ID parent
 * @param PA_ReportLine_ID parent
 * @param source copy source
 * @param trxName transaction
 * @return Report Source
 */
public static MReportSource copy(final Properties ctx, final int AD_Client_ID, final int AD_Org_ID,
		final int PA_ReportLine_ID, final MReportSource source, final String trxName)
{
	final MReportSource retValue = new MReportSource(ctx, 0, trxName);
	PO.copyValues(source, retValue, AD_Client_ID, AD_Org_ID);
	retValue.setPA_ReportLine_ID(PA_ReportLine_ID);
	return retValue;
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:20,代码来源:MReportSource.java


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