本文整理汇总了Java中org.compiere.model.PO.get_KeyColumns方法的典型用法代码示例。如果您正苦于以下问题:Java PO.get_KeyColumns方法的具体用法?Java PO.get_KeyColumns怎么用?Java PO.get_KeyColumns使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.compiere.model.PO
的用法示例。
在下文中一共展示了PO.get_KeyColumns方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getId
import org.compiere.model.PO; //导入方法依赖的package包/类
@Override
public int getId(final Object model)
{
final PO po = POWrapper.getStrictPO(model);
if (po == null)
{
return -1;
}
final String[] keyColumns = po.get_KeyColumns();
if (keyColumns == null || keyColumns.length != 1)
{
return -1;
}
return po.get_ID();
}
示例2: POZoomSource
import org.compiere.model.PO; //导入方法依赖的package包/类
private POZoomSource(final PO po, final int adWindowId)
{
Check.assumeNotNull(po, "Parameter po is not null");
this.po = po;
this.adWindowId = adWindowId;
final String[] keyColumnNamesArr = po.get_KeyColumns();
if (keyColumnNamesArr == null)
{
keyColumnNames = ImmutableList.of();
}
else
{
keyColumnNames = ImmutableList.copyOf(keyColumnNamesArr);
}
}
示例3: getLinkColumnName
import org.compiere.model.PO; //导入方法依赖的package包/类
private String getLinkColumnName(final PO masterPO, final MTable tableEmbedded)
{
final String[] keyColumns = masterPO.get_KeyColumns();
if (keyColumns == null || keyColumns.length == 0)
{
throw new AdempiereException("No key columns found for " + masterPO);
}
if (keyColumns.length == 1)
{
return keyColumns[0];
}
final Properties ctx = masterPO.getCtx();
final String masterTableName = masterPO.get_TableName();
final IAppDictionaryBL appDictBL = Services.get(IAppDictionaryBL.class);
for (final String keyColumn : keyColumns)
{
final MTable table = appDictBL.getReferencedTable(ctx, masterTableName, keyColumn);
if (table != null && table.getAD_Table_ID() == tableEmbedded.getAD_Table_ID())
{
return keyColumn;
}
}
throw new AdempiereException("No relevant link column found on " + masterPO + " for " + tableEmbedded);
}
示例4: whereClauseMatches
import org.compiere.model.PO; //导入方法依赖的package包/类
boolean whereClauseMatches(final Object model)
{
final String where = getSQLWhere();
if (Check.isEmpty(where, true))
{
MCAdvCommissionRelevantPO.logger.debug("whereClause is empty. Returning true");
return true;
}
final PO po = InterfaceWrapperHelper.getPO(model);
final String[] keyColumns = po.get_KeyColumns();
if (keyColumns.length != 1)
{
throw new AdempiereException(po + " has " + keyColumns.length
+ " key columns; Should have one. " + this
+ " fails to match where clause");
}
final String whereClause = keyColumns[0] + "=" + po.get_ID() + " AND ( " + where + " ) ";
final boolean match = new Query(po.getCtx(), po.get_TableName(), whereClause, po.get_TrxName()).setOnlyActiveRecords(true).match();
MCAdvCommissionRelevantPO.logger.debug("whereClause='" + whereClause + "' matches po='" + po + "':" + match);
return match;
}
示例5: openFor
import org.compiere.model.PO; //导入方法依赖的package包/类
public GridWindowHelper openFor(Object poModel)
{
Assert.assertNull("Another window already opened - " + gridWindow, gridWindow);
logger.info("PO=" + poModel);
final PO po = InterfaceWrapperHelper.getPO(poModel);
final String tableName = po.get_TableName();
String keyColumn = po.get_KeyColumns()[0];
final int recordId = po.get_ID();
// figure out whether we has IsSOTrx=Y
final boolean soTrx;
if (po.get_ColumnIndex("IsSOTrx") > -1)
{
soTrx = po.get_ValueAsBoolean("IsSOTrx");
}
else
{
soTrx = true;
}
currentGridTab = loadWindow(tableName, soTrx);
final MQuery query = MQuery.getEqualQuery(keyColumn, recordId);
logger.info("Query=" + query);
currentGridTab.setQuery(query);
currentGridTab.query(false);
Assert.assertEquals("Invalid row count - " + currentGridTab, 1, currentGridTab.getRowCount());
currentGridTab.setCurrentRow(0);
Assert.assertEquals("Wrong record selected on " + currentGridTab, recordId, currentGridTab.getValue(keyColumn));
return this;
}
示例6: 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);
}
}
}
示例7: testStart
import org.compiere.model.PO; //导入方法依赖的package包/类
/**
* Test Start condition
* @param wf workflow
* @param document document
* @return true if WF should be started
*/
private boolean testStart (MWorkflow wf, PO document)
{
boolean retValue = false;
String logic = wf.getDocValueLogic();
logic = logic.substring(4); // "SQL="
//
String tableName = document.get_TableName();
String[] keyColumns = document.get_KeyColumns();
if (keyColumns.length != 1)
{
log.error("Tables with more then one key column not supported - "
+ tableName + " = " + keyColumns.length);
return false;
}
String keyColumn = keyColumns[0];
StringBuffer sql = new StringBuffer("SELECT ")
.append(keyColumn).append(" FROM ").append(tableName)
.append(" WHERE AD_Client_ID=? AND ") // #1
.append(keyColumn).append("=? AND ") // #2
.append(logic)
// Duplicate Open Workflow test
.append(" AND NOT EXISTS (SELECT * FROM AD_WF_Process wfp ")
.append("WHERE wfp.AD_Table_ID=? AND wfp.Record_ID=") // #3
.append(tableName).append(".").append(keyColumn)
.append(" AND wfp.AD_Workflow_ID=?") // #4
.append(" AND SUBSTR(wfp.WFState,1,1)='O')");
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql.toString(), document.get_TrxName());
pstmt.setInt (1, wf.getAD_Client_ID());
pstmt.setInt (2, document.get_ID());
pstmt.setInt (3, document.get_Table_ID());
pstmt.setInt (4, wf.getAD_Workflow_ID());
rs = pstmt.executeQuery ();
if (rs.next ())
retValue = true;
}
catch (Exception e)
{
log.error("Logic=" + logic
+ " - SQL=" + sql.toString(), e);
}
finally
{
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return retValue;
}
示例8: getSummary
import org.compiere.model.PO; //导入方法依赖的package包/类
/**
* Get Document Summary
*
* @return PO Summary
*/
public String getSummary()
{
PO po = getPO();
if (po == null)
return null;
StringBuffer sb = new StringBuffer();
String[] keyColumns = po.get_KeyColumns();
if ((keyColumns != null) && (keyColumns.length > 0))
sb.append(Services.get(IMsgBL.class).translate(getCtx(), keyColumns[0])).append(" ");
int index = po.get_ColumnIndex("DocumentNo");
if (index != -1)
sb.append(po.get_Value(index)).append(": ");
index = po.get_ColumnIndex("SalesRep_ID");
Integer sr = null;
if (index != -1)
sr = (Integer)po.get_Value(index);
else
{
index = po.get_ColumnIndex("AD_User_ID");
if (index != -1)
sr = (Integer)po.get_Value(index);
}
if (sr != null)
{
String userFullname = Services.get(IUserDAO.class).retrieveUserFullname(sr.intValue());
if (!Check.isEmpty(userFullname))
sb.append(userFullname).append(" ");
}
//
index = po.get_ColumnIndex("C_BPartner_ID");
if (index != -1)
{
Integer bp = (Integer)po.get_Value(index);
if (bp != null)
{
MBPartner partner = MBPartner.get(getCtx(), bp.intValue());
if (partner != null)
sb.append(partner.getName()).append(" ");
}
}
return sb.toString();
}
示例9: exportRecord
import org.compiere.model.PO; //导入方法依赖的package包/类
/**
* Export a limited number of POs for the given format and where clause.
*
* @param exportFormat
* @param where
* @param ReplicationMode
* @param ReplicationType
* @param ReplicationEvent
* @param limit limit the number of exported records. This makes sense when we want to export only a few sample records for the given format.
* @return
* @throws Exception
*/
public Document exportRecord(final MEXPFormat exportFormat, final String where, final Integer ReplicationMode, final String ReplicationType, final Integer ReplicationEvent,
final IReplicationAccessContext racCtx)
throws Exception
{
final I_AD_Client client = Services.get(IClientDAO.class).retriveClient(exportFormat.getCtx(), m_AD_Client_ID);
final MTable table = MTable.get(exportFormat.getCtx(), exportFormat.getAD_Table_ID());
log.info("Table = " + table);
// metas: begin: build where clause
final StringBuffer whereClause = new StringBuffer("1=1");
if (!Check.isEmpty(exportFormat.getWhereClause(), true))
{
whereClause.append(" AND (").append(exportFormat.getWhereClause()).append(")");
}
if (!Check.isEmpty(where))
{
whereClause.append(" AND (").append(where).append(")");
}
// metas: end
final Collection<PO> records = new Query(exportFormat.getCtx(), table.getTableName(), whereClause.toString(), exportFormat.get_TrxName())
.setOnlyActiveRecords(true)
.setApplyAccessFilter(racCtx.isApplyAccessFilter())
.setLimit(racCtx.getLimit())
.list();
for (final PO po : records)
{
log.info("Client = " + client.toString());
log.trace("po.getAD_Org_ID() = " + po.getAD_Org_ID());
log.trace("po.get_TrxName() = " + po.get_TrxName());
if (po.get_TrxName() == null || po.get_TrxName().equals(""))
{
po.set_TrxName("exportRecord");
}
if (po.get_KeyColumns().length < 1)
{
throw new Exception(Services.get(IMsgBL.class).getMsg(po.getCtx(), "ExportNoneColumnKeyNotSupported")); // TODO: Create Mesagge.
}
outDocument = createNewDocument();
final HashMap<String, Integer> variableMap = new HashMap<String, Integer>();
final Element rootElement = generateRootElement(exportFormat, outDocument, ReplicationMode, ReplicationType, ReplicationEvent, client);
generateExportFormat(outDocument, rootElement, exportFormat, po, variableMap, racCtx);
} // finish record read
return outDocument;
}
示例10: doIt
import org.compiere.model.PO; //导入方法依赖的package包/类
/**
* Process - Generate Export Format
* @return info
*/
protected String doIt () throws Exception
{
outDocument = createNewDocument();
MClient client = MClient.get (getCtx(), p_AD_Client_ID);
log.info(client.toString());
// TODO - get proper Export Format!
int EXP_Format_ID = 1000000;
MTable table = MTable.get(getCtx(), AD_Table_ID);
log.info("Table = " + table);
PO po = table.getPO (p_Record_ID, get_TrxName());
if (po.get_KeyColumns().length > 1 || po.get_KeyColumns().length < 1) {
throw new Exception(Msg.getMsg (getCtx(), "ExportMultiColumnNotSupported"));
}
MEXPFormat exportFormat = new MEXPFormat(getCtx(), EXP_Format_ID, get_TrxName());
StringBuffer sql = new StringBuffer("SELECT * ")
.append("FROM ").append(table.getTableName()).append(" ")
.append("WHERE ").append(po.get_KeyColumns()[0]).append("=?")
;
if (exportFormat.getWhereClause() != null & !"".equals(exportFormat.getWhereClause())) {
sql.append(" AND ").append(exportFormat.getWhereClause());
}
ResultSet rs = null;
PreparedStatement pstmt = null;
try
{
pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
pstmt.setInt(1, p_Record_ID);
rs = pstmt.executeQuery();
if (rs.next())
{
HashMap<String, Integer> variableMap = new HashMap<String, Integer>();
variableMap.put(TOTAL_SEGMENTS, new Integer(1));
Element rootElement = outDocument.createElement(exportFormat.getValue());
rootElement.appendChild(outDocument.createComment(exportFormat.getDescription()));
outDocument.appendChild(rootElement);
generateExportFormat(rootElement, exportFormat, rs, po, p_Record_ID, variableMap);
}
} finally {
try {
if (rs != null) rs.close();
if (pstmt != null) pstmt.close();
} catch (SQLException ex) {/*ignored*/}
rs = null;
pstmt = null;
}
/* int C_EDIProcessorType_ID = ediProcessor.getC_EDIProcessorType_ID();
X_C_EDIProcessorType ediProcessType = new X_C_EDIProcessorType(getCtx(), C_EDIProcessorType_ID, get_TrxName() );
String javaClass = ediProcessType.getJavaClass();
try {
Class clazz = Class.forName(javaClass);
IOutbandEdiProcessor outbandProcessor = (IOutbandEdiProcessor)clazz.newInstance();
outbandProcessor.process(getCtx(), ediProcessor, result.toString(), "C_Invoice-"+p_Record_ID+".txt", Trx.get( get_TrxName(), false ));
} catch (Exception e) {
result = new StringBuffer( e.toString() );
}
*/
addLog(0, null, null, Msg.getMsg (getCtx(), "ExportProcessResult") + "\n" + outDocument.toString());
return outDocument.toString();
}