6817a.diff
new/src/com/goldencode/p2j/persist/AbstractTempTable.java 2023-01-13 10:21:10 +0000 | ||
---|---|---|
156 | 156 |
/** Default prefix for the name of a temp-table copied with COPY-TEMP-TABLE. */ |
157 | 157 |
protected static final String DEFAULT_COPY_TEMP_TABLE_PREFIX = "cpy"; |
158 | 158 |
|
159 |
/** Default buffer handle. */
|
|
160 |
protected handle defaultBufferHandle = null;
|
|
161 |
|
|
159 |
/** Default buffer. */ |
|
160 |
protected BufferImpl defaultBuffer = null;
|
|
161 | ||
162 | 162 |
/** Corresponds ERROR-STRING attribute. */ |
163 | 163 |
protected final character errorString = new character(); |
164 | 164 |
|
... | ... | |
259 | 259 |
@Override |
260 | 260 |
public character primaryIndex() |
261 | 261 |
{ |
262 |
BufferImpl defBuf = (BufferImpl) defaultBufferHandle.getResource(); |
|
263 |
if (defBuf == null) |
|
262 |
if (defaultBuffer == null) |
|
264 | 263 |
{ |
265 | 264 |
return new character(); |
266 | 265 |
} |
267 | 266 |
|
268 |
return defBuf.primaryIndex();
|
|
267 |
return defaultBuffer.primaryIndex();
|
|
269 | 268 |
} |
270 | 269 |
|
271 | 270 |
/** |
... | ... | |
557 | 556 |
} |
558 | 557 |
|
559 | 558 |
// delegate to default buffer |
560 |
return defaultBufferHandle.unwrapDereferenceable().derefPoly(memberName);
|
|
559 |
return defaultBuffer.derefPoly(memberName);
|
|
561 | 560 |
} |
562 | 561 |
|
563 | 562 |
/** |
564 | 563 |
* All kind of temp-tables can be dereferenced. This should be propagated to the |
565 |
* {@link #defaultBufferHandle} if not null. Otherwise, the table was not prepared
|
|
564 |
* {@link #defaultBuffer} if not null. Otherwise, the table was not prepared |
|
566 | 565 |
* (for dynamic temp-tables). |
567 | 566 |
* |
568 | 567 |
* @param memberName |
569 | 568 |
* The name of the member to be extracted. |
570 | 569 |
* |
571 |
* @return The value of the member - processed by the {@link #defaultBufferHandle}.
|
|
570 |
* @return The value of the member - processed by the {@link #defaultBuffer}. |
|
572 | 571 |
*/ |
573 | 572 |
@Override |
574 | 573 |
public BaseDataType dereference(String memberName) |
... | ... | |
579 | 578 |
return null; |
580 | 579 |
} |
581 | 580 |
|
582 |
return defaultBufferHandle.unwrapDereferenceable().dereference(memberName);
|
|
581 |
return defaultBuffer.dereference(memberName); |
|
583 | 582 |
} |
584 | 583 |
|
585 | 584 |
/** |
586 | 585 |
* All kind of temp-tables can be dereferenced. This should be propagated to the |
587 |
* {@link #defaultBufferHandle} if not null. Otherwise, the table was not prepared
|
|
586 |
* {@link #defaultBuffer} if not null. Otherwise, the table was not prepared |
|
588 | 587 |
* (for dynamic temp-tables). |
589 | 588 |
* |
590 | 589 |
* @param type |
... | ... | |
592 | 591 |
* @param memberName |
593 | 592 |
* The name of the member to be extracted. |
594 | 593 |
* |
595 |
* @return The value of the member - processed by the {@link #defaultBufferHandle}.
|
|
594 |
* @return The value of the member - processed by the {@link #defaultBuffer}. |
|
596 | 595 |
*/ |
597 | 596 |
@Override |
598 | 597 |
public <T extends BaseDataType> T dereference(Class<T> type, String memberName) |
... | ... | |
603 | 602 |
return null; |
604 | 603 |
} |
605 | 604 |
|
606 |
return defaultBufferHandle.unwrapDereferenceable().dereference(type, memberName);
|
|
605 |
return defaultBuffer.dereference(type, memberName); |
|
607 | 606 |
} |
608 | 607 |
|
609 | 608 |
/** |
610 | 609 |
* All kind of temp-tables can be dereferenced. This should be propagated to the |
611 |
* {@link #defaultBufferHandle} if not null. Otherwise, the table was not prepared
|
|
610 |
* {@link #defaultBuffer} if not null. Otherwise, the table was not prepared |
|
612 | 611 |
* (for dynamic temp-tables) and the uninitialized error should be displayed. |
613 | 612 |
* |
614 | 613 |
* @param memberName |
... | ... | |
625 | 624 |
return; |
626 | 625 |
} |
627 | 626 | |
628 |
defaultBufferHandle.unwrapDereferenceable().dereference(memberName, value);
|
|
627 |
defaultBuffer.dereference(memberName, value); |
|
629 | 628 |
} |
630 | 629 |
|
631 | 630 |
/** |
... | ... | |
844 | 843 |
return new logical(false); |
845 | 844 |
} |
846 | 845 |
|
847 |
BufferImpl defBuff = (BufferImpl) defaultBufferHandle.unwrapBuffer(); |
|
848 |
if (computeTableType() == BeforeType.BEFORE && defBuff.hasBeforeBufferConstraints()) |
|
846 |
if (computeTableType() == BeforeType.BEFORE && defaultBuffer.hasBeforeBufferConstraints()) |
|
849 | 847 |
{ |
850 | 848 |
ErrorManager.recordOrShowError(11946); |
851 | 849 |
// You cannot EMPTY a BEFORE-TABLE, Use ACCEPT-CHANGES or EMPTY the AFTER-TABLE. |
852 | 850 |
return new logical(false); |
853 | 851 |
} |
854 | 852 |
|
855 |
AbstractTempTable bTable = (AbstractTempTable) getBeforeTable().getResource();
|
|
853 |
AbstractTempTable bTable = (AbstractTempTable) getBeforeTableNative();
|
|
856 | 854 |
if (bTable != null) |
857 | 855 |
{ |
858 | 856 |
((BufferImpl) bTable.defaultBuffer().getDMOProxy()).setUpBeforeBuffer(true); |
... | ... | |
1162 | 1160 |
return; |
1163 | 1161 |
} |
1164 | 1162 |
|
1165 |
handle bt = getBeforeTable();
|
|
1166 |
if (bt.isUnknown())
|
|
1163 |
TempTable bt = getBeforeTableNative();
|
|
1164 |
if (bt == null)
|
|
1167 | 1165 |
{ |
1168 | 1166 |
if (_dynamic()) |
1169 | 1167 |
{ |
... | ... | |
1193 | 1191 |
@Override |
1194 | 1192 |
public handle getBeforeTable() |
1195 | 1193 |
{ |
1194 |
return new handle(getBeforeTableNative()); |
|
1195 |
} |
|
1196 | ||
1197 |
/** |
|
1198 |
* Get the handle of the before-image table that corresponds to the after-image table |
|
1199 |
* currently associated with this temp-table handle. |
|
1200 |
* |
|
1201 |
* @return the value of {@code BEFORE-TABLE} as described above. |
|
1202 |
*/ |
|
1203 |
@Override |
|
1204 |
public TempTable getBeforeTableNative() |
|
1205 |
{ |
|
1196 | 1206 |
if (computeTableType() == BeforeType.AFTER) |
1197 | 1207 |
{ |
1198 |
return new handle(peerTable);
|
|
1208 |
return peerTable;
|
|
1199 | 1209 |
} |
1200 |
|
|
1201 |
return new handle();
|
|
1210 | ||
1211 |
return null;
|
|
1202 | 1212 |
} |
1203 |
|
|
1213 | ||
1204 | 1214 |
/** |
1205 | 1215 |
* Get the handle of the after-image table that corresponds to the before-image table |
1206 | 1216 |
* currently associated with this temp-table handle. |
... | ... | |
1210 | 1220 |
@Override |
1211 | 1221 |
public handle getAfterTable() |
1212 | 1222 |
{ |
1223 |
return new handle(getAfterTableNative()); |
|
1224 |
} |
|
1225 | ||
1226 |
/** |
|
1227 |
* Get the handle of the after-image table that corresponds to the before-image table |
|
1228 |
* currently associated with this temp-table handle. |
|
1229 |
* |
|
1230 |
* @return the value of {@code AFTER-TABLE} as described above. |
|
1231 |
*/ |
|
1232 |
@Override |
|
1233 |
public TempTable getAfterTableNative() |
|
1234 |
{ |
|
1213 | 1235 |
if (computeTableType() == BeforeType.BEFORE) |
1214 | 1236 |
{ |
1215 |
return new handle(peerTable);
|
|
1237 |
return peerTable;
|
|
1216 | 1238 |
} |
1217 |
|
|
1218 |
return new handle();
|
|
1239 | ||
1240 |
return null;
|
|
1219 | 1241 |
} |
1220 |
|
|
1242 | ||
1221 | 1243 |
/** |
1222 | 1244 |
* Get the handle of the TEMP-TABLE in the original source {@code DataSet} object that |
1223 | 1245 |
* corresponds to the TEMP-TABLE currently associated with this TEMP-TABLE handle. |
... | ... | |
1229 | 1251 |
{ |
1230 | 1252 |
return new handle(originTable); |
1231 | 1253 |
} |
1232 |
|
|
1254 | ||
1255 |
/** |
|
1256 |
* Get the handle of the TEMP-TABLE in the original source {@code DataSet} object that |
|
1257 |
* corresponds to the TEMP-TABLE currently associated with this TEMP-TABLE handle. |
|
1258 |
* |
|
1259 |
* @return the current origin table. |
|
1260 |
*/ |
|
1261 |
@Override |
|
1262 |
public TempTable getOriginTable() |
|
1263 |
{ |
|
1264 |
return originTable; |
|
1265 |
} |
|
1266 | ||
1233 | 1267 |
/** |
1234 | 1268 |
* Implementation of the READ-XML method. Reads XML data from the specified data source into |
1235 | 1269 |
* this object. |
... | ... | |
1658 | 1692 |
// Dynamic temp-table must be in PREPARED state for WRITE-XML Methods. |
1659 | 1693 |
return new logical(false); |
1660 | 1694 |
} |
1661 |
|
|
1662 |
return defaultBufferHandle().unwrapBuffer().writeXml(target, |
|
1663 |
formatted, |
|
1664 |
encoding, |
|
1665 |
schemaLocation, |
|
1666 |
writeXmlSchema, |
|
1667 |
minXmlSchema, |
|
1668 |
beforeImage, |
|
1669 |
noInitialVals); |
|
1695 | ||
1696 |
Buffer buf = defaultBufferHandleNative(); |
|
1697 |
if (buf == null) |
|
1698 |
{ |
|
1699 |
return new logical(false); |
|
1700 |
} |
|
1701 | ||
1702 |
return buf.writeXml(target, |
|
1703 |
formatted, |
|
1704 |
encoding, |
|
1705 |
schemaLocation, |
|
1706 |
writeXmlSchema, |
|
1707 |
minXmlSchema, |
|
1708 |
beforeImage, |
|
1709 |
noInitialVals); |
|
1670 | 1710 |
} |
1671 | 1711 |
|
1672 | 1712 |
/** |
... | ... | |
1769 | 1809 |
// Dynamic temp-table must be in PREPARED state for WRITE-XML Methods. |
1770 | 1810 |
return new logical(false); |
1771 | 1811 |
} |
1772 |
|
|
1773 |
return defaultBufferHandle().unwrapBuffer().writeXmlSchema( |
|
1774 |
target, formatted, encoding, minXmlSchema, omitInitVal); |
|
1812 | ||
1813 | ||
1814 |
Buffer buf = defaultBufferHandleNative(); |
|
1815 |
if (buf == null) |
|
1816 |
{ |
|
1817 |
return new logical(false); |
|
1818 |
} |
|
1819 | ||
1820 |
return buf.writeXmlSchema(target, formatted, encoding, minXmlSchema, omitInitVal); |
|
1775 | 1821 |
} |
1776 | 1822 |
|
1777 | 1823 |
/** |
... | ... | |
2150 | 2196 |
// throw something? |
2151 | 2197 |
return new logical(false); |
2152 | 2198 |
} |
2153 |
|
|
2154 |
return defaultBufferHandle().unwrapBuffer().writeJson( |
|
2155 |
target, formatted, encoding, omitInitialValues, omitOuterObject, writeBeforeImage); |
|
2199 | ||
2200 |
Buffer buf = defaultBufferHandleNative(); |
|
2201 |
if (buf == null) |
|
2202 |
{ |
|
2203 |
return new logical(false); |
|
2204 |
} |
|
2205 | ||
2206 |
return buf.writeJson(target, formatted, encoding, omitInitialValues, omitOuterObject, writeBeforeImage); |
|
2156 | 2207 |
} |
2157 | 2208 |
|
2158 | 2209 |
/** |
... | ... | |
2453 | 2504 |
*/ |
2454 | 2505 |
public String tableDefinition() |
2455 | 2506 |
{ |
2456 |
WrappedResource r = this.defaultBufferHandle.getResource();
|
|
2507 |
WrappedResource r = this.defaultBuffer; |
|
2457 | 2508 |
if (r != null && r.valid()) |
2458 | 2509 |
{ |
2459 | 2510 |
return ((BufferImpl) r).tableDefinition(); |
... | ... | |
2518 | 2569 |
*/ |
2519 | 2570 |
TemporaryBuffer defaultBuffer() |
2520 | 2571 |
{ |
2521 |
if (defaultBufferHandle == null)
|
|
2572 |
if (defaultBuffer == null) |
|
2522 | 2573 |
{ |
2523 | 2574 |
return null; |
2524 | 2575 |
} |
2525 | 2576 |
|
2526 |
return (TemporaryBuffer) RecordBuffer.get((DataModelObject) defaultBufferHandle.getResource());
|
|
2577 |
return (TemporaryBuffer) RecordBuffer.get((DataModelObject) defaultBuffer); |
|
2527 | 2578 |
} |
2528 | 2579 |
|
2529 | 2580 |
/** |
new/src/com/goldencode/p2j/persist/BufferFieldImpl.java 2023-01-13 10:21:10 +0000 | ||
---|---|---|
320 | 320 |
@Override |
321 | 321 |
public logical available() |
322 | 322 |
{ |
323 |
handle buf = bufferHandle(); |
|
324 |
if (!buf.unwrapBuffer()._available()) |
|
323 |
if (!getBuffer()._available()) |
|
325 | 324 |
{ |
326 | 325 |
return new logical(); |
327 | 326 |
} |
... | ... | |
533 | 532 |
@Override |
534 | 533 |
public BaseDataType value() |
535 | 534 |
{ |
536 |
handle buf = bufferHandle();
|
|
537 |
if (buf._isValid())
|
|
535 |
Buffer buf = getBuffer();
|
|
536 |
if (buf != null && buf.valid())
|
|
538 | 537 |
{ |
539 |
if (buf.unwrapBuffer()._available())
|
|
538 |
if (buf._available()) |
|
540 | 539 |
{ |
541 | 540 |
if (fieldRef.getExtent() != null) |
542 | 541 |
{ |
... | ... | |
550 | 549 |
} |
551 | 550 |
return retVal; |
552 | 551 |
} |
553 |
else if (((BufferImpl) buf.unwrapBuffer()).buffer().isUnknownMode())
|
|
552 |
else if (((BufferImpl) buf).buffer().isUnknownMode()) |
|
554 | 553 |
{ |
555 | 554 |
return fieldRef.unknownValue(); |
556 | 555 |
} |
557 | 556 |
} |
558 | 557 |
|
559 |
String bn = !buf._isValid() ? "<UNKNOWN>" : buf.unwrap().name().toStringMessage();
|
|
558 |
String bn = buf == null || !buf.valid() ? "<UNKNOWN>" : buf.name().toStringMessage();
|
|
560 | 559 |
ErrorManager.recordOrShowError( |
561 | 560 |
91, |
562 | 561 |
String.format("No %s record is available", bn), |
... | ... | |
799 | 798 |
@Override |
800 | 799 |
public handle bufferHandle() |
801 | 800 |
{ |
802 |
return new handle((Buffer) getParentBuffer().getDMOProxy()); |
|
803 |
} |
|
804 |
|
|
801 |
return new handle(getBuffer()); |
|
802 |
} |
|
803 | ||
804 |
/** |
|
805 |
* Returns the handle of the buffer object to which the buffer-field belongs. |
|
806 |
* |
|
807 |
* @return the handle of the buffer object to which the buffer-field belongs. |
|
808 |
*/ |
|
809 |
public Buffer getBuffer() |
|
810 |
{ |
|
811 |
return (Buffer) getParentBuffer().getDMOProxy(); |
|
812 |
} |
|
813 | ||
805 | 814 |
/** |
806 | 815 |
* Conversion of LITERAL-QUESTION attribute (KW_LIT_QSTN). |
807 | 816 |
* |
new/src/com/goldencode/p2j/persist/BufferHandle.java 2023-01-13 10:21:10 +0000 | ||
---|---|---|
85 | 85 |
*/ |
86 | 86 |
@LegacyAttribute(name = "DEFAULT-BUFFER-HANDLE") |
87 | 87 |
public handle defaultBufferHandle(); |
88 | ||
89 |
/** |
|
90 |
* Obtain the buffer that was created by default for this temporary table. Every |
|
91 |
* dynamic temp-table is created with at least one buffer. This buffer object is |
|
92 |
* returned by this method. |
|
93 |
* |
|
94 |
* Note that it cannot be called until the table has been prepared using |
|
95 |
* <code>tempTablePrepare()</code> method. |
|
96 |
* |
|
97 |
* This method is the P2J equivalent of <code>DEFAULT-BUFFER-HANDLE</code> |
|
98 |
* attribute. |
|
99 |
* |
|
100 |
* @return The default buffer for the temporary table. |
|
101 |
*/ |
|
102 |
public Buffer defaultBufferHandleNative(); |
|
88 | 103 |
} |
new/src/com/goldencode/p2j/persist/BufferImpl.java 2023-01-13 10:21:10 +0000 | ||
---|---|---|
414 | 414 |
private boolean deleting; |
415 | 415 |
|
416 | 416 |
/** The last query this buffer was added/set to. */ |
417 |
private handle lastQuery = null;
|
|
417 |
private QueryWrapper lastQuery = null;
|
|
418 | 418 |
|
419 | 419 |
/** The current dataset. May be {@code null}. */ |
420 | 420 |
private DataSet dataSet = null; |
... | ... | |
2279 | 2279 |
@Override |
2280 | 2280 |
public handle bufferField(String fieldName) |
2281 | 2281 |
{ |
2282 |
return new handle(bufferFieldNative(fieldName)); |
|
2283 |
} |
|
2284 | ||
2285 |
/** |
|
2286 |
* Implementation of BUFFER-FIELD() method (KW_BUF_FLD). |
|
2287 |
* |
|
2288 |
* Gets a particular field within a buffer. |
|
2289 |
* |
|
2290 |
* @param fieldName |
|
2291 |
* The legacy field name. A CHARACTER string expression representing the name |
|
2292 |
* of the field in the buffer. |
|
2293 |
* |
|
2294 |
* @return a particular field in the buffer. |
|
2295 |
*/ |
|
2296 |
public BufferField bufferFieldNative(String fieldName) |
|
2297 |
{ |
|
2282 | 2298 |
Property property = buffer().getDmoInfo().byLegacyName(fieldName); |
2283 | 2299 |
if (property != null) |
2284 | 2300 |
{ |
2285 | 2301 |
BufferFieldImpl field = bufferFieldForProperty(property.name); |
2286 | 2302 |
if (field != null) |
2287 | 2303 |
{ |
2288 |
return new handle(field);
|
|
2304 |
return field;
|
|
2289 | 2305 |
} |
2290 | 2306 |
} |
2291 | 2307 | |
2292 | 2308 |
String msg = "BUFFER-FIELD " + fieldName + " was not found in buffer " + doGetName(); |
2293 | 2309 |
ErrorManager.recordOrShowError(7351, msg, false, false, false); |
2294 |
|
|
2310 | ||
2295 | 2311 |
// return unknown handle |
2296 |
return new handle();
|
|
2312 |
return null;
|
|
2297 | 2313 |
} |
2298 |
|
|
2314 | ||
2299 | 2315 |
/** |
2300 | 2316 |
* Conversion of BUFFER-COPY() method (KW_BUF_COPY). |
2301 | 2317 |
* |
... | ... | |
6413 | 6429 |
@Override |
6414 | 6430 |
public handle getQueryAsHandle() |
6415 | 6431 |
{ |
6416 |
// bit of maintenance |
|
6417 |
if (lastQuery != null && !lastQuery._isValid()) |
|
6418 |
{ |
|
6419 |
lastQuery = null; |
|
6420 |
} |
|
6421 |
|
|
6422 |
return lastQuery == null ? new handle() : new handle(lastQuery.getResource()); |
|
6432 |
return lastQuery == null ? new handle() : new handle(lastQuery); |
|
6423 | 6433 |
} |
6424 | 6434 |
|
6425 | 6435 |
/** |
... | ... | |
6588 | 6598 |
if (crtState == Buffer.ROW_MODIFIED || crtState == Buffer.ROW_CREATED) |
6589 | 6599 |
{ |
6590 | 6600 |
// find and update the after-image/record |
6591 |
BufferImpl after = (BufferImpl) afterBuffer().unwrapBuffer();
|
|
6601 |
BufferImpl after = afterBufferNative();
|
|
6592 | 6602 |
after.findByRowID(this.afterRowid()); |
6593 | 6603 |
RecordBuffer afterRecBuf = after.buffer(); |
6594 | 6604 |
afterRecBuf.peerRowid(new rowid()); |
... | ... | |
6627 | 6637 |
} |
6628 | 6638 |
|
6629 | 6639 |
// find and update the after-image/record |
6630 |
BufferImpl after = (BufferImpl) afterBuffer().unwrapBuffer();
|
|
6640 |
BufferImpl after = afterBufferNative();
|
|
6631 | 6641 |
TemporaryBuffer afterImage = (TemporaryBuffer) after.buffer(); |
6632 | 6642 |
RecordBuffer recBuf = buffer(); |
6633 | 6643 |
switch (recBuf.rowState().toJavaIntegerType()) |
... | ... | |
7079 | 7089 |
BufferImpl ref = null; |
7080 | 7090 |
for (int k = 1; k <= newDSrc._getNumSourceBuffers(); k++) |
7081 | 7091 |
{ |
7082 |
BufferImpl buffer = (BufferImpl) newDSrc.getSourceBuffer(k).unwrapBuffer();
|
|
7092 |
BufferImpl buffer = newDSrc.getSourceBufferNative(k);
|
|
7083 | 7093 |
if (buffer.hasField(myFieldName)) |
7084 | 7094 |
{ |
7085 | 7095 |
// if multiple buffers have the same field, then the last buffer having this field will be used |
... | ... | |
7155 | 7165 |
BufferImpl buffer = null; |
7156 | 7166 |
for (int j = 1; j <= newDSrc._getNumSourceBuffers(); j++) |
7157 | 7167 |
{ |
7158 |
buffer = (BufferImpl) newDSrc.getSourceBuffer(j).unwrapBuffer();
|
|
7168 |
buffer = newDSrc.getSourceBufferNative(j);
|
|
7159 | 7169 |
if (buffer.hasFieldEx(fld2NoEx)) |
7160 | 7170 |
{ |
7161 | 7171 |
found = true; |
... | ... | |
7294 | 7304 |
@Override |
7295 | 7305 |
public handle afterBuffer() |
7296 | 7306 |
{ |
7307 |
return new handle(afterBufferNative()); |
|
7308 |
} |
|
7309 | ||
7310 |
/** |
|
7311 |
* Obtain the default buffer of the after-image table that corresponds to |
|
7312 |
* the buffer of the before-image table currently associated with this buffer. |
|
7313 |
* |
|
7314 |
* @return The value of {@code AFTER-BUFFER} attribute as described above. |
|
7315 |
*/ |
|
7316 |
public BufferImpl afterBufferNative() |
|
7317 |
{ |
|
7297 | 7318 |
if (!isBeforeBuffer()) |
7298 | 7319 |
{ |
7299 | 7320 |
// permanent and simple temp-tables do not have BEFORE/AFTER buffers |
7300 |
return new handle();
|
|
7321 |
return null;
|
|
7301 | 7322 |
} |
7302 |
|
|
7303 |
return new handle(peerBuffer);
|
|
7323 | ||
7324 |
return peerBuffer;
|
|
7304 | 7325 |
} |
7305 |
|
|
7326 | ||
7306 | 7327 |
/** |
7307 | 7328 |
* Obtain the {@code rowid} of the row in the original before-image table that corresponds to |
7308 | 7329 |
* the row in the change table currently associated with this buffer handle. |
... | ... | |
7355 | 7376 |
@Override |
7356 | 7377 |
public handle beforeBuffer() |
7357 | 7378 |
{ |
7379 |
return new handle(beforeBufferNative()); |
|
7380 |
} |
|
7381 | ||
7382 |
/** |
|
7383 |
* Obtain the default buffer of the before-image table that corresponds to |
|
7384 |
* the buffer of the after-image table currently associated with this buffer. |
|
7385 |
* |
|
7386 |
* @return The value of {@code BEFORE-BUFFER} attribute as described above. |
|
7387 |
*/ |
|
7388 |
public BufferImpl beforeBufferNative() |
|
7389 |
{ |
|
7358 | 7390 |
if (!isAfterBuffer()) |
7359 | 7391 |
{ |
7360 | 7392 |
// permanent and simple temp-tables do not have BEFORE/AFTER buffers |
7361 |
return new handle();
|
|
7393 |
return null;
|
|
7362 | 7394 |
} |
7363 |
|
|
7364 |
return new handle(peerBuffer);
|
|
7395 | ||
7396 |
return peerBuffer;
|
|
7365 | 7397 |
} |
7366 |
|
|
7398 | ||
7367 | 7399 |
/** |
7368 | 7400 |
* The list of field name pairs for all fields (in comm-delimited format) in a {@code DataSet} |
7369 | 7401 |
* temp-table buffer that are mapped to corresponding fields in an attached data-source object. |
... | ... | |
7811 | 7843 |
return new logical(false); |
7812 | 7844 |
} |
7813 | 7845 |
|
7814 |
return new logical(((TemporaryBuffer) buffer()).markNew( |
|
7815 |
(BufferImpl) beforeBuffer().unwrapBuffer())); |
|
7846 |
return new logical(((TemporaryBuffer) buffer()).markNew(beforeBufferNative())); |
|
7816 | 7847 |
} |
7817 | 7848 |
|
7818 | 7849 |
/** |
... | ... | |
7939 | 7970 |
return new logical(true); // already has before image/record |
7940 | 7971 |
} |
7941 | 7972 |
|
7942 |
BufferImpl b4Buffer = (BufferImpl) beforeBuffer().unwrapBuffer();
|
|
7973 |
BufferImpl b4Buffer = beforeBufferNative();
|
|
7943 | 7974 |
RecordBuffer b4RecBuf = b4Buffer.buffer(); |
7944 | 7975 |
RecordBuffer recBuf = buffer(); |
7945 | 7976 |
b4Buffer.setUpBeforeBuffer(true); |
... | ... | |
8226 | 8257 |
BufferImpl[] srcBuffs = new BufferImpl[srcBufCount]; |
8227 | 8258 |
for (int k = 0; k < srcBufCount; k++) |
8228 | 8259 |
{ |
8229 |
srcBuffs[k] = (BufferImpl) dataSource.getSourceBuffer(k + 1).unwrapBuffer();
|
|
8260 |
srcBuffs[k] = dataSource.getSourceBufferNative(k + 1);
|
|
8230 | 8261 |
srcBuffs[k].buffer().initialize(); |
8231 | 8262 |
} |
8232 | 8263 |
|
... | ... | |
8850 | 8881 |
// check the argument first: it must be an AFTER or BEFORE buffer: |
8851 | 8882 |
BufferImpl srcBefore = (BufferImpl) original.unwrapBuffer(); |
8852 | 8883 |
BufferImpl srcAfter = null; |
8853 |
handle xHandle = srcBefore.beforeBuffer();
|
|
8854 |
if (xHandle.isUnknown())
|
|
8884 |
BufferImpl buf = srcBefore.beforeBufferNative();
|
|
8885 |
if (buf == null)
|
|
8855 | 8886 |
{ |
8856 |
xHandle = srcBefore.afterBuffer();
|
|
8857 |
if (xHandle.isUnknown())
|
|
8887 |
buf = srcBefore.afterBufferNative();
|
|
8888 |
if (buf == null)
|
|
8858 | 8889 |
{ |
8859 | 8890 |
ErrorManager.recordOrShowError(11925, srcBefore.doGetName()); |
8860 | 8891 |
// GET/MERGE-CHANGES require a BEFORE-TABLE for table <name>. |
... | ... | |
8862 | 8893 |
} |
8863 | 8894 |
else |
8864 | 8895 |
{ |
8865 |
srcAfter = (BufferImpl) xHandle.unwrapBuffer();
|
|
8896 |
srcAfter = buf;
|
|
8866 | 8897 |
} |
8867 | 8898 |
} |
8868 | 8899 |
else |
8869 | 8900 |
{ |
8870 | 8901 |
// oops, [xHandle] is the BEFORE buffer and [srcBefore] is the AFTER buffer, fixing: |
8871 | 8902 |
srcAfter = srcBefore; |
8872 |
srcBefore = (BufferImpl) xHandle.unwrapBuffer();
|
|
8903 |
srcBefore = buf;
|
|
8873 | 8904 |
} |
8874 | 8905 |
|
8875 | 8906 |
// now check the current buffer: it also must be an AFTER or BEFORE buffer: |
8876 | 8907 |
BufferImpl dstBefore = null; |
8877 | 8908 |
BufferImpl dstAfter = null; |
8878 |
xHandle = beforeBuffer();
|
|
8879 |
if (xHandle.isUnknown())
|
|
8909 |
buf = beforeBufferNative();
|
|
8910 |
if (buf == null)
|
|
8880 | 8911 |
{ |
8881 |
xHandle = afterBuffer();
|
|
8882 |
if (xHandle.isUnknown())
|
|
8912 |
buf = afterBufferNative();
|
|
8913 |
if (buf == null)
|
|
8883 | 8914 |
{ |
8884 | 8915 |
ErrorManager.recordOrShowError(11925, doGetName()); |
8885 | 8916 |
// GET/MERGE-CHANGES require a BEFORE-TABLE for table <name>. |
... | ... | |
8888 | 8919 |
else |
8889 | 8920 |
{ |
8890 | 8921 |
dstBefore = this; |
8891 |
dstAfter = (BufferImpl) xHandle.unwrapBuffer();
|
|
8922 |
dstAfter = buf;
|
|
8892 | 8923 |
} |
8893 | 8924 |
} |
8894 | 8925 |
else |
8895 | 8926 |
{ |
8896 |
dstBefore = (BufferImpl) xHandle.unwrapBuffer();
|
|
8927 |
dstBefore = buf;
|
|
8897 | 8928 |
dstAfter = this; |
8898 | 8929 |
} |
8899 | 8930 |
|
... | ... | |
9050 | 9081 |
} |
9051 | 9082 |
else |
9052 | 9083 |
{ |
9053 |
afterBufferChanges = (BufferImpl) afterBuffer().unwrapBuffer();
|
|
9084 |
afterBufferChanges = peerBuffer;
|
|
9054 | 9085 |
} |
9055 | 9086 |
|
9056 | 9087 |
BufferImpl origBuffer; |
... | ... | |
9058 | 9089 |
if (original == null) |
9059 | 9090 |
{ |
9060 | 9091 |
TempTable parentTable = this.buffer().getParentTable(); |
9061 |
handle originTableHandle = parentTable.getOriginHandle();
|
|
9062 |
if (originTableHandle.isUnknown() || !originTableHandle._isValid())
|
|
9092 |
originTable = parentTable.getOriginTable();
|
|
9093 |
if (originTable == null || !originTable.valid())
|
|
9063 | 9094 |
{ |
9064 | 9095 |
ErrorManager.recordOrShowError(11944, afterBufferChanges.doGetName()); |
9065 | 9096 |
// MERGE-ROW-CHANGES finds ORIGIN-HANDLE in table <name> is no longer valid. |
9066 | 9097 |
return new logical(false); |
9067 | 9098 |
} |
9068 |
originTable = originTableHandle.unwrapTempTable(); |
|
9069 |
origBuffer = (BufferImpl) originTable.defaultBufferHandle().unwrapBuffer(); |
|
9099 |
origBuffer = (BufferImpl) originTable.defaultBufferHandleNative(); |
|
9070 | 9100 |
} |
9071 | 9101 |
else |
9072 | 9102 |
{ |
... | ... | |
9228 | 9258 |
|
9229 | 9259 |
RecordBuffer beforeBuf = buffer(); |
9230 | 9260 |
Persistence persistence = beforeBuf.getPersistence(); |
9231 |
BufferImpl after = (BufferImpl) afterBuffer().unwrapBuffer();
|
|
9261 |
BufferImpl after = afterBufferNative();
|
|
9232 | 9262 |
RecordBuffer afterBuf = after.buffer(); |
9233 | 9263 |
|
9234 | 9264 |
// invalidate index-based caches because of low-level operations: |
... | ... | |
9310 | 9340 |
// TODO: but if it still happens? which error we we throw? |
9311 | 9341 |
return new logical(false); |
9312 | 9342 |
} |
9313 |
return new logical(buffer.rejectChanges((BufferImpl) afterBuffer().unwrapBuffer()));
|
|
9343 |
return new logical(buffer.rejectChanges(afterBufferNative()));
|
|
9314 | 9344 |
} |
9315 | 9345 |
|
9316 | 9346 |
/** |
... | ... | |
9389 | 9419 |
return; |
9390 | 9420 |
} |
9391 | 9421 |
|
9392 |
this.lastQuery = new handle(qry.getResource());
|
|
9422 |
this.lastQuery = (QueryWrapper) qry.getResource();
|
|
9393 | 9423 |
} |
9394 | 9424 |
|
9395 | 9425 |
/** |
... | ... | |
9400 | 9430 |
*/ |
9401 | 9431 |
protected void resetLastQuery(QueryWrapper qry) |
9402 | 9432 |
{ |
9403 |
if (lastQuery != null && (lastQuery.isUnknown() || lastQuery.get() == qry))
|
|
9433 |
if (lastQuery == qry)
|
|
9404 | 9434 |
{ |
9405 | 9435 |
this.lastQuery = null; |
9406 | 9436 |
} |
... | ... | |
9506 | 9536 |
} |
9507 | 9537 |
|
9508 | 9538 |
TempTable tempTable = TempTableBuilder.asTempTable((Temporary) this); |
9509 |
|
|
9510 |
handle ttBefore = tempTable.getBeforeTable();
|
|
9511 |
if (!ttBefore.isUnknown())
|
|
9539 | ||
9540 |
TempTable ttBefore = tempTable.getBeforeTableNative();
|
|
9541 |
if (ttBefore != null)
|
|
9512 | 9542 |
{ |
9513 |
peerBuffer = (BufferImpl) ttBefore.unwrapTempTable().defaultBufferHandle().getResource();
|
|
9543 |
peerBuffer = (BufferImpl) ttBefore.defaultBufferHandle().getResource(); |
|
9514 | 9544 |
peerBuffer = peerBuffer.ref(); |
9515 | 9545 |
beforeBufferType = BeforeType.AFTER; |
9516 | 9546 |
return; |
9517 | 9547 |
} |
9518 | 9548 |
|
9519 |
handle ttAfter = tempTable.getAfterTable();
|
|
9520 |
if (!ttAfter.isUnknown())
|
|
9549 |
TempTable ttAfter = tempTable.getAfterTableNative();
|
|
9550 |
if (ttAfter != null)
|
|
9521 | 9551 |
{ |
9522 |
peerBuffer = (BufferImpl) ttAfter.unwrapTempTable().defaultBufferHandle().getResource();
|
|
9552 |
peerBuffer = (BufferImpl) ttAfter.defaultBufferHandle().getResource(); |
|
9523 | 9553 |
peerBuffer = peerBuffer.ref(); |
9524 | 9554 |
beforeBufferType = BeforeType.BEFORE; |
9525 | 9555 |
return; |
... | ... | |
11141 | 11171 |
peerBuffer.error(true); // the AFTER-IMAGE of this BEFORE-IMAGE |
11142 | 11172 |
|
11143 | 11173 |
TempTable beforeTable = TempTableBuilder.asTempTable((Temporary) this); |
11144 |
TempTable afterTable = (TempTable) beforeTable.getAfterTable().getResource();
|
|
11174 |
TempTable afterTable = beforeTable.getAfterTableNative();
|
|
11145 | 11175 |
|
11146 | 11176 |
beforeTable.error(true); // the TEMP-TABLE of current BUFFER |
11147 | 11177 |
afterTable.error(true); // the TEMP-TABLE of the AFTER-BUFFER |
new/src/com/goldencode/p2j/persist/DBUtils.java 2023-01-13 10:43:46 +0000 | ||
---|---|---|
690 | 690 |
* If <code>fieldHandle</code> references an extent field, multiple field references |
691 | 691 |
* for each extent element are returned. |
692 | 692 |
*/ |
693 |
public static FieldReference[] getFieldForAddLikeColumn(P2JQuery query, handle fieldHandle)
|
|
693 |
public static FieldReference[] getFieldForAddLikeColumn(QueryWrapper query, handle fieldHandle)
|
|
694 | 694 |
{ |
695 | 695 |
if (!fieldHandle._isValid()) |
696 | 696 |
{ |
... | ... | |
713 | 713 |
int bufferCount = query.numBuffers().intValue(); |
714 | 714 |
for (int i = 1; i <= bufferCount; i++) |
715 | 715 |
{ |
716 |
Buffer buffer = query.bufferHandle(i).unwrapBuffer();
|
|
716 |
Buffer buffer = query.bufferHandleNative(i);
|
|
717 | 717 |
if (buffer.equals(srcBuffer)) |
718 | 718 |
{ |
719 | 719 |
match = true; |
... | ... | |
763 | 763 |
* If the field expression references an extent field, multiple field references |
764 | 764 |
* for each extent element are returned. |
765 | 765 |
*/ |
766 |
public static FieldReference[] getFieldForAddLikeColumn(P2JQuery query, character fieldExpression)
|
|
766 |
public static FieldReference[] getFieldForAddLikeColumn(QueryWrapper query, character fieldExpression)
|
|
767 | 767 |
{ |
768 | 768 |
String fullSource = fieldExpression.getValue(); |
769 | 769 |
if (fullSource == null) |
... | ... | |
799 | 799 |
int bufferCount = query.numBuffers().intValue(); |
800 | 800 |
for (int i = 1; i <= bufferCount; i++) |
801 | 801 |
{ |
802 |
Buffer buffer = query.bufferHandle(i).unwrapBuffer();
|
|
802 |
Buffer buffer = query.bufferHandleNative(i);
|
|
803 | 803 |
RecordBuffer recordBuffer = ((BufferImpl) buffer).buffer(); |
804 | 804 |
|
805 | 805 |
String bufferName = buffer.name().getValue(); |
... | ... | |
924 | 924 |
* <p>Error with code <code>2</code>: if the buffer name is not specified, there are multiple |
925 | 925 |
* buffers containing the field with the give name.</p> |
926 | 926 |
*/ |
927 |
public static BufferField getMatchingBufferField(P2JQuery query, String fullFieldName)
|
|
927 |
public static BufferField getMatchingBufferField(QueryWrapper query, String fullFieldName)
|
|
928 | 928 |
throws NumberedException |
929 | 929 |
{ |
930 |
Buffer targetBuffer = null; |
|
930 |
BufferImpl targetBuffer = null;
|
|
931 | 931 |
String fieldName; |
932 | 932 |
String bufName = null; |
933 | 933 | |
... | ... | |
946 | 946 |
int numBuffers = query.numBuffers().intValue(); |
947 | 947 |
for (int i = 1; i <= numBuffers; i++) |
948 | 948 |
{ |
949 |
Buffer buffer = query.bufferHandle(i).unwrapBuffer();
|
|
949 |
BufferImpl buffer = (BufferImpl) query.bufferHandleNative(i);
|
|
950 | 950 |
if (bufName != null && !bufName.equalsIgnoreCase(buffer.name().getValue())) |
951 | 951 |
{ |
952 | 952 |
// mismatching buffer name |
953 | 953 |
continue; |
954 | 954 |
} |
955 | 955 | |
956 |
String property = TableMapper.getPropertyName(((BufferImpl)buffer).buffer(), fieldName);
|
|
956 |
String property = TableMapper.getPropertyName(buffer.buffer(), fieldName);
|
|
957 | 957 |
if (property == null) |
958 | 958 |
{ |
959 | 959 |
// mismatching field name |
... | ... | |
963 | 963 |
if (bufName != null) |
964 | 964 |
{ |
965 | 965 |
// matching field name and buffer name |
966 |
return buffer.bufferField(fieldName).unwrapBufferField();
|
|
966 |
return buffer.bufferFieldNative(fieldName);
|
|
967 | 967 |
} |
968 | 968 |
else |
969 | 969 |
{ |
... | ... | |
985 | 985 |
throw new NumberedException("", 1); |
986 | 986 |
} |
987 | 987 | |
988 |
return targetBuffer.bufferField(fieldName).unwrapBufferField();
|
|
988 |
return targetBuffer.bufferFieldNative(fieldName);
|
|
989 | 989 |
} |
990 | 990 | |
991 | 991 |
/** |
new/src/com/goldencode/p2j/persist/DataRelation.java 2023-01-13 10:21:10 +0000 | ||
---|---|---|
363 | 363 |
{ |
364 | 364 |
return new handle(childBuffer); |
365 | 365 |
} |
366 |
|
|
366 | ||
367 |
/** |
|
368 |
* Obtain the buffer of the child member of this data-relation object. This method |
|
369 |
* corresponds to the real-only {@code CHILD-BUFFER} attribute. |
|
370 |
* |
|
371 |
* @return the buffer of the child member. |
|
372 |
*/ |
|
373 |
public Buffer getChildBufferNative() |
|
374 |
{ |
|
375 |
return childBuffer; |
|
376 |
} |
|
377 | ||
367 | 378 |
/** |
368 | 379 |
* Obtain the handle to the {@code DataSet} query that contains the currently selected row in |
369 | 380 |
* the {@code BindingSource}. Corresponds to {@code CURRENT-QUERY} ABL method. |
... | ... | |
675 | 686 |
{ |
676 | 687 |
return new handle(parentBuffer); |
677 | 688 |
} |
678 |
|
|
689 | ||
690 |
/** |
|
691 |
* Obtain the buffer of the parent member. This is the FWD implementation of |
|
692 |
* {@code PARENT-BUFFER} ABL read-only attribute |
|
693 |
* |
|
694 |
* @return the buffer of the parent member. |
|
695 |
*/ |
|
696 |
public Buffer getParentBufferNative() |
|
697 |
{ |
|
698 |
return parentBuffer; |
|
699 |
} |
|
700 | ||
679 | 701 |
/** |
680 | 702 |
* Checks whether child rows of a {@code DataSet} temp-table buffer are nested within their |
681 | 703 |
* parent rows when writing the XML representation of {@code DataSet} object that contains |
... | ... | |
1104 | 1126 |
query.delete(); |
1105 | 1127 |
} |
1106 | 1128 |
|
1107 |
handle hQuery = TypeFactory.handle(); |
|
1108 |
QueryWrapper.createQuery(hQuery); |
|
1109 |
query = (QueryWrapper) hQuery.unwrapQuery(); |
|
1129 |
query = QueryWrapper.createQueryNative(null); |
|
1110 | 1130 |
query.setBuffers(childBuffer); |
1111 | 1131 |
query.setSubstitutionBuffers(parentBuffer); |
1112 | 1132 |
return query.prepare(sb.toString()).booleanValue(); |
new/src/com/goldencode/p2j/persist/DataSet.java 2023-01-13 10:21:10 +0000 | ||
---|---|---|
628 | 628 |
for (int k = 1; k <= bufCnt; k++) |
629 | 629 |
{ |
630 | 630 |
// copy data for each corresponding temp-table |
631 |
Buffer srcBuf = dsSource.bufferHandle(k).unwrapBuffer();
|
|
631 |
Buffer srcBuf = dsSource.getBufferByIndex(k);
|
|
632 | 632 |
Temporary srcDMO = TemporaryBuffer.getDefaultBuffer(srcBuf.tableHandle()); |
633 |
BufferImpl targetDmo = (BufferImpl) dsTarget.bufferHandle(k).getResource();
|
|
633 |
BufferImpl targetDmo = dsTarget.getBufferByIndex(k);
|
|
634 | 634 |
rowid srcRec = dsTarget.isReferenceOnly() && srcBuf._available() ? srcBuf.rowID() : null; |
635 | 635 |
boolean res = TemporaryBuffer.copyAllRows( |
636 | 636 |
srcRec, |
... | ... | |
1307 | 1307 |
TempTable srcTempTable = TempTableBuilder.asTempTable((Temporary) src); |
1308 | 1308 |
|
1309 | 1309 |
// this is a matter if there is a before-table, not if TRACKING-CHANGES is set... |
1310 |
if (srcTempTable.getBeforeTable().isUnknown())
|
|
1310 |
if (srcTempTable.getBeforeTableNative() != null)
|
|
1311 | 1311 |
{ |
1312 | 1312 |
continue; |
1313 | 1313 |
} |
... | ... | |
2127 | 2127 |
continue; |
2128 | 2128 |
} |
2129 | 2129 |
|
2130 |
logical ok = buffer.beforeBuffer().unwrapBuffer().acceptChanges();
|
|
2130 |
logical ok = buffer.beforeBufferNative().acceptChanges();
|
|
2131 | 2131 |
if (!ok.booleanValue()) |
2132 | 2132 |
{ |
2133 | 2133 |
return ok; |
... | ... | |
2156 | 2156 |
continue; |
2157 | 2157 |
} |
2158 | 2158 |
|
2159 |
logical ok = buffer.beforeBuffer().unwrapBuffer().rejectChanges();
|
|
2159 |
logical ok = buffer.beforeBufferNative().rejectChanges();
|
|
2160 | 2160 |
if (!ok.booleanValue()) |
2161 | 2161 |
{ |
2162 | 2162 |
return ok; |
... | ... | |
2745 | 2745 |
@Override |
2746 | 2746 |
public handle getTopBuffer(long index) |
2747 | 2747 |
{ |
2748 |
return new handle(getTopBufferNative(index)); |
|
2749 |
} |
|
2750 | ||
2751 |
/** |
|
2752 |
* Gets the top-level buffer of this {@code DataSet} object at the specified index position. |
|
2753 |
* |
|
2754 |
* @param index |
|
2755 |
* The 1-based index of the top-level buffer. |
|
2756 |
* |
|
2757 |
* @return the top-level buffer at the specified index position. |
|
2758 |
*/ |
|
2759 |
public BufferImpl getTopBufferNative(long index) |
|
2760 |
{ |
|
2748 | 2761 |
if (index < 1) |
2749 | 2762 |
{ |
2750 |
return new handle();
|
|
2763 |
return null;
|
|
2751 | 2764 |
} |
2752 |
|
|
2765 | ||
2753 | 2766 |
List<Buffer> candidates = getTopBufferList(); |
2754 | 2767 |
if (_getNumTopBuffers() != candidates.size()) |
2755 | 2768 |
{ |
2756 | 2769 |
// well, this should NEVER happen! |
2757 | 2770 |
throw new RuntimeException("The size of TOP-BUFFER list does not match NUM-TOP-BUFFER"); |
2758 | 2771 |
} |
2759 |
|
|
2760 |
return index - 1 >= candidates.size() ? new handle() |
|
2761 |
: new handle(candidates.get((int) (index - 1))); |
|
2772 | ||
2773 |
return index - 1 >= candidates.size() ? null : (BufferImpl) candidates.get((int) (index - 1)); |
|
2762 | 2774 |
} |
2763 |
|
|
2775 | ||
2764 | 2776 |
/** |
2765 | 2777 |
* Gets the top-level buffer of this {@code DataSet} object at the specified index position. |
2766 | 2778 |
* |
... | ... | |
2808 | 2820 |
return new handle(); |
2809 | 2821 |
} |
2810 | 2822 |
|
2811 |
handle topBuffer = getTopBuffer(index);
|
|
2812 |
if (topBuffer.isUnknown())
|
|
2823 |
BufferImpl topBuffer = getTopBufferNative(index);
|
|
2824 |
if (topBuffer == null)
|
|
2813 | 2825 |
{ |
2814 | 2826 |
return new handle(); |
2815 | 2827 |
} |
2816 |
return getTopNavQuery((BufferImpl) topBuffer.unwrapBuffer());
|
|
2828 |
return getTopNavQuery(topBuffer);
|
|
2817 | 2829 |
} |
2818 | 2830 |
|
2819 | 2831 |
/** |
... | ... | |
2908 | 2920 |
return; |
2909 | 2921 |
} |
2910 | 2922 |
|
2911 |
BufferImpl topBuffer = (BufferImpl) getTopBuffer(index).unwrapBuffer();
|
|
2923 |
BufferImpl topBuffer = getTopBufferNative(index);
|
|
2912 | 2924 |
_setTopBufferQuery(queryHandle, topBuffer); |
2913 | 2925 |
} |
2914 | 2926 |
|
... | ... | |
3026 | 3038 |
for (int i = 0; i < relations.size(); i++) |
3027 | 3039 |
{ |
3028 | 3040 |
DataRelation rel = relations.get(i); |
3029 |
Buffer cb = rel.getChildBuffer().unwrapBuffer(); |
|
3041 |
Buffer cb = rel.getChildBufferNative(); |
|
3042 |
if (cb == null) |
|
3043 |
{ |
|
3044 |
continue; |
|
3045 |
} |
|
3030 | 3046 |
int uuid = cb.getUniqueID().intValue(); |
3031 | 3047 |
if (childBuffers.contains(uuid)) |
3032 | 3048 |
{ |
... | ... | |
3580 | 3596 |
else |
3581 | 3597 |
{ |
3582 | 3598 |
// and, if so, it is of the proper type (RECID) |
3583 |
handle hfparent = bufChild.bufferField(parLink); |
|
3584 |
if (hfparent.isUnknown() || |
|
3585 |
!"RECID".equalsIgnoreCase(hfparent.unwrapBufferField().getDataType().getValue())) |
|
3599 |
BufferField fparent = bufChild.bufferFieldNative(parLink); |
|
3600 |
if (fparent == null || !"RECID".equalsIgnoreCase(fparent.getDataType().getValue())) |
|
3586 | 3601 |
{ |
3587 | 3602 |
ErrorManager.recordOrShowError(16028, parLink); |
3588 | 3603 |
// ADD-PARENT-ID-RELATION parent-id-field <field> is not valid. |
... | ... | |
4284 | 4299 |
public handle bufferHandle(int64 bufIndex) |
4285 | 4300 |
{ |
4286 | 4301 |
int idx = bufIndex.isUnknown() ? 0 : bufIndex.intValue(); |
4287 |
|
|
4288 |
if (idx < 1 || idx > buffers.size()) |
|
4289 |
{ |
|
4290 |
return new handle(); |
|
4291 |
} |
|
4292 |
|
|
4293 |
handle h = new handle(); |
|
4294 |
h.assign(buffers.get(idx - 1)); |
|
4295 |
return h; |
|
4302 |
return new handle(getBufferByIndex(idx)); |
|
4296 | 4303 |
} |
4297 | 4304 |
|
4298 | 4305 |
/** |
... | ... | |
5538 | 5545 |
{ |
5539 | 5546 |
return ref().buffers; |
5540 | 5547 |
} |
5541 |
|
|
5548 | ||
5549 |
/** |
|
5550 |
* Lookup a buffer by its index. |
|
5551 |
* |
|
5552 |
* @param bufIndex |
|
5553 |
* The index to search among the list of buffers. |
|
5554 |
* |
|
5555 |
* @return The buffer whose index was specified or {@code null} when there is no match. |
|
5556 |
*/ |
|
5557 |
public BufferImpl getBufferByIndex(int bufIndex) |
|
5558 |
{ |
|
5559 |
if (bufIndex < 1 || bufIndex > buffers.size()) |
|
5560 |
{ |
|
5561 |
return null; |
|
5562 |
} |
|
5563 | ||
5564 |
return buffers.get(bufIndex - 1); |
|
5565 |
} |
|
5566 | ||
5542 | 5567 |
/** |
5543 | 5568 |
* Copy output data for the linked {@code DataSet} parameter, if any. |
5544 | 5569 |
* |
... | ... | |
5689 | 5714 |
DataRelation relation = relations.get(i); |
5690 | 5715 |
if (relation._isActive() && |
5691 | 5716 |
!relation._isReposition() && |
5692 |
relation.getChildBuffer().unwrapBuffer().getUniqueID().intValue() == childUid) |
|
5717 |
// HC: can getChildBufferNative() return null in this case? should this case be handled? |
|
5718 |
relation.getChildBufferNative().getUniqueID().intValue() == childUid) |
|
5693 | 5719 |
{ |
5694 | 5720 |
return relation; |
5695 | 5721 |
} |
... | ... | |
5727 | 5753 |
{ |
5728 | 5754 |
continue; |
5729 | 5755 |
} |
5730 |
if (child && rel.getChildBuffer().unwrapBuffer() == buffer)
|
|
5756 |
if (child && rel.getChildBufferNative() == buffer)
|
|
5731 | 5757 |
{ |
5732 | 5758 |
ret.add(rel); |
5733 | 5759 |
} |
5734 |
if (parent && rel.getParentBuffer().unwrapBuffer() == buffer)
|
|
5760 |
if (parent && rel.getParentBufferNative() == buffer)
|
|
5735 | 5761 |
{ |
5736 | 5762 |
ret.add(rel); |
5737 | 5763 |
} |
... | ... | |
6109 | 6135 |
} |
6110 | 6136 |
return null; |
6111 | 6137 |
} |
6112 |
|
|
6138 | ||
6113 | 6139 |
/** |
6114 | 6140 |
* Obtain the current {@code TOP-NAV-QUERY} for a specified buffer. Uses lazy initialization: |
6115 | 6141 |
* if not exist one is created (and prepared, but not open) now. |
... | ... | |
6126 | 6152 |
QueryWrapper query = topNavQueries.get(buffer); |
6127 | 6153 |
if (query == null || !query.valid()) |
6128 | 6154 |
{ |
6129 |
handle hQuery = TypeFactory.handle(); |
|
6130 |
QueryWrapper.createQuery(hQuery); |
|
6131 |
query = (QueryWrapper) hQuery.unwrapQuery(); |
|
6155 |
query = QueryWrapper.createQueryNative(null); |
|
6132 | 6156 |
query.setBuffers(buffer); |
6133 | 6157 |
query.prepare("FOR EACH " + buffer.name().toStringMessage()); |
6134 | 6158 |
topNavQueries.put(buffer, query); |
... | ... | |
6344 | 6368 |
DataRelation relation = relations.get(i); |
6345 | 6369 |
if (relation._isActive() && !relation._isReposition()) |
6346 | 6370 |
{ |
6347 |
topBuffers.remove(relation.getChildBuffer().unwrapBuffer());
|
|
6371 |
topBuffers.remove(relation.getChildBufferNative());
|
|
6348 | 6372 |
} |
6349 | 6373 |
} |
6350 | 6374 |
|
... | ... | |
6405 | 6429 |
|
6406 | 6430 |
// TODO: anything to copy at the before-table? |
6407 | 6431 |
copyTempTableOptions((AbstractTempTable) srcAfterBuff.tableHandle().getResource(), newAtt); |
6408 |
|
|
6409 |
newBuffers[i] = (BufferImpl) newAtt.defaultBufferHandle().unwrapBuffer(); |
|
6432 | ||
6433 |
// HC: should null be handled here? |
|
6434 |
newBuffers[i] = (BufferImpl) newAtt.defaultBufferHandleNative(); |
|
6410 | 6435 |
} |
6411 | 6436 |
setBuffers(newBuffers); |
6412 | 6437 |
// in OE 11.6 the [xmlNodeName] was observed to be copied in a different fashion |
... | ... | |
6424 | 6449 |
for (int i = 0; i < dataRelations.size(); i++) |
6425 | 6450 |
{ |
6426 | 6451 |
DataRelation srcRel = dataRelations.get(i); |
6427 |
Buffer srcChBuffer = srcRel.getChildBuffer().unwrapBuffer();
|
|
6428 |
Buffer srcParBuffer = srcRel.getParentBuffer().unwrapBuffer();
|
|
6452 |
Buffer srcChBuffer = srcRel.getChildBufferNative();
|
|
6453 |
Buffer srcParBuffer = srcRel.getParentBufferNative();
|
|
6429 | 6454 |
|
6430 | 6455 |
Buffer bufParent = newBuffers[positionOf(srcBuffers, srcParBuffer)]; |
6431 | 6456 |
Buffer bufChild = newBuffers[positionOf(srcBuffers, srcChBuffer)]; |
new/src/com/goldencode/p2j/persist/DataSetContainer.java 2023-01-13 10:21:10 +0000 | ||
---|---|---|
288 | 288 |
for (int k = 0; k < bufCnt; k++) |
289 | 289 |
{ |
290 | 290 |
tableDefinitions.add( |
291 |
new DsTableDefinition((BufferImpl) ds.bufferHandle(k + 1).getResource(), copyRows));
|
|
291 |
new DsTableDefinition(ds.getBufferByIndex(k + 1), copyRows));
|
|
292 | 292 |
} |
293 | 293 |
} |
294 | 294 |
new/src/com/goldencode/p2j/persist/DataSource.java 2023-01-13 10:21:10 +0000 | ||
---|---|---|
147 | 147 |
private BufferImpl datasetBuffer = null; |
148 | 148 |
|
149 | 149 |
/** The query that defines the buffers for the data-source object. */ |
150 |
private final handle query = new handle();
|
|
150 |
private QueryWrapper query = null;
|
|
151 | 151 |
|
152 | 152 |
/** |
153 | 153 |
* The current value of the {@code PREFER-DATASET} attribute. Default value is {@code false}. |
... | ... | |
387 | 387 |
@Override |
388 | 388 |
public handle getQueryAsHandle() |
389 | 389 |
{ |
390 |
return query._isValid() ? new handle(query.getResource()) : new handle();
|
|
390 |
return new handle(query);
|
|
391 | 391 |
} |
392 | 392 |
|
393 | 393 |
/** |
... | ... | |
1124 | 1124 |
return new character(); |
1125 | 1125 |
} |
1126 | 1126 |
|
1127 |
TempTable bt = (TempTable) datasetBuffer.buffer().getParentTable().getBeforeTable().getResource();
|
|
1127 |
TempTable bt = datasetBuffer.buffer().getParentTable().getBeforeTableNative();
|
|
1128 | 1128 |
return new character(String.join(bt.name().toStringMessage(), ret)); |
1129 | 1129 |
} |
1130 | 1130 |
|
... | ... | |
1183 | 1183 |
return new character(); |
1184 | 1184 |
} |
1185 | 1185 |
|
1186 |
TempTable bt = |
|
1187 |
(TempTable) datasetBuffer.buffer().getParentTable().getBeforeTable().getResource(); |
|
1186 |
TempTable bt = datasetBuffer.buffer().getParentTable().getBeforeTableNative(); |
|
1188 | 1187 |
return new character(String.join(bt.name().toStringMessage(), ret)); |
1189 | 1188 |
} |
1190 | 1189 |
|
... | ... | |
1618 | 1617 |
@Override |
1619 | 1618 |
public handle getSourceBuffer(long bufIndex) |
1620 | 1619 |
{ |
1620 |
return new handle(getSourceBufferNative(bufIndex)); |
|
1621 |
} |
|
1622 | ||
1623 |
/** |
|
1624 |
* Gets the handle to the source buffer in the data-source object at the specified index |
|
1625 |
* position. |
|
1626 |
* |
|
1627 |
* @param bufIndex |
|
1628 |
* The index of the requested buffer. |
|
1629 |
* |
|
1630 |
* @return the specified buffer. |
|
1631 |
*/ |
|
1632 |
public BufferImpl getSourceBufferNative(long bufIndex) |
|
1633 |
{ |
|
1621 | 1634 |
if (bufIndex < 1 || bufIndex > buffers.size()) |
1622 | 1635 |
{ |
1623 |
return new handle();
|
|
1636 |
return null;
|
|
1624 | 1637 |
} |
1625 |
|
|
1626 |
return new handle(buffers.get((int) (bufIndex - 1)));
|
|
1638 | ||
1639 |
return buffers.get((int) (bufIndex - 1));
|
|
1627 | 1640 |
} |
1628 |
|
|
1641 | ||
1629 | 1642 |
/** |
1630 | 1643 |
* Gets the handle to the source buffer in the data-source object at the specified index |
1631 | 1644 |
* position. |
... | ... | |
1705 | 1718 |
*/ |
1706 | 1719 |
int _getNumSourceBuffers() |
1707 | 1720 |
{ |
1708 |
if (buffers.isEmpty() && query._isValid())
|
|
1721 |
if (buffers.isEmpty() && query != null && query.valid())
|
|
1709 | 1722 |
{ |
1710 |
QueryWrapper qw = (QueryWrapper) query.getResource(); |
|
1711 |
int n = (int) qw.numBuffers().getValue(); |
|
1723 |
int n = (int) query.numBuffers().getValue(); |
|
1712 | 1724 |
for (int k = 1; k <= n; k++) |
1713 | 1725 |
{ |
1714 |
addSourceBufferImpl((BufferImpl) qw.bufferHandle(k).getResource(), null);
|
|
1726 |
addSourceBufferImpl((BufferImpl) query.bufferHandle(k).getResource(), null);
|
|
1715 | 1727 |
} |
1716 | 1728 |
} |
1717 | 1729 |
|
... | ... | |
1837 | 1849 |
|
1838 | 1850 |
for (DataRelation rel : rels) |
1839 | 1851 |
{ |
1840 |
String parBuff = rel.getParentBuffer().unwrapBuffer().name().toStringMessage();
|
|
1852 |
String parBuff = rel.getParentBufferNative().name().toStringMessage();
|
|
1841 | 1853 |
if (rel.isParentIdRelation().booleanValue()) |
1842 | 1854 |
{ |
1843 | 1855 |
// in PARENT-ID relations, the FILL WHERE is unknown |
... | ... | |
1926 | 1938 |
} |
1927 | 1939 |
} |
1928 | 1940 |
|
1929 |
this.query.assign(qry);
|
|
1941 |
this.query = ((QueryWrapper) qry);
|
|
1930 | 1942 |
setParentBuffer(); |
1931 | 1943 |
} |
1932 | 1944 |
|
... | ... | |
2072 | 2084 |
if (saveWhere != null) |
2073 | 2085 |
{ |
2074 | 2086 |
TempTable tempTable = TempTableBuilder.asTempTable((Temporary) datasetBuffer); |
2075 |
handle bt = tempTable.getBeforeTable();
|
|
2076 |
if (bt == null || bt.isUnknown())
|
|
2087 |
TempTable bt = tempTable.getBeforeTableNative();
|
|
2088 |
if (bt == null) |
|
2077 | 2089 |
{ |
2078 | 2090 |
if (!tempTable.isTrackingChanges().booleanValue()) |
2079 | 2091 |
{ |
... | ... | |
2097 | 2109 |
} |
2098 | 2110 |
|
2099 | 2111 |
TempTable tempTable = TempTableBuilder.asTempTable((Temporary) datasetBuffer); |
2100 |
handle bt = tempTable.getBeforeTable();
|
|
2101 |
if (bt == null || bt.isUnknown())
|
|
2112 |
TempTable bt = tempTable.getBeforeTableNative();
|
|
2113 |
if (bt == null) |
|
2102 | 2114 |
{ |
2103 | 2115 |
if (!tempTable.isTrackingChanges().booleanValue()) |
2104 | 2116 |
{ |
... | ... | |
2123 | 2135 |
} |
2124 | 2136 |
} |
2125 | 2137 |
|
2126 |
String btName = bt.unwrap().name().toStringMessage();
|
|
2138 |
String btName = bt.name().toStringMessage(); |
|
2127 | 2139 |
List<String> tokens = new ArrayList<>(6); |
2128 | 2140 |
StringBuilder sb = new StringBuilder(); |
2129 | 2141 |
|
... | ... | |
2202 | 2214 |
*/ |
2203 | 2215 |
private void setParentBuffer() |
2204 | 2216 |
{ |
2205 |
if (datasetBuffer != null && query != null && query._isValid())
|
|
2217 |
if (datasetBuffer != null && query != null && query.valid())
|
|
2206 | 2218 |
{ |
2207 | 2219 |
DataRelation relation = (DataRelation) datasetBuffer.parentRelation().getResource(); |
2208 | 2220 |
if (relation != null) |
2209 | 2221 |
{ |
2210 |
((QueryWrapper) query.getResource()) |
|
2211 |
.setSubstitutionBuffers((Buffer) relation.getParentBuffer().getResource()); |
|
2222 |
query.setSubstitutionBuffers((Buffer) relation.getParentBuffer().getResource()); |
|
2212 | 2223 |
} |
2213 | 2224 |
} |
2214 | 2225 |
} |
new/src/com/goldencode/p2j/persist/DsRelationDefinition.java 2023-01-13 10:43:46 +0000 | ||
---|---|---|
129 | 129 |
public DsRelationDefinition(DataRelation rel) |
130 | 130 |
{ |
131 | 131 |
this.name = rel.name().toStringMessage(); |
132 |
this.parentBuffer = rel.getParentBuffer().unwrap().name().toStringMessage();
|
|
133 |
this.childBuffer = rel.getChildBuffer().unwrap().name().toStringMessage();
|
|
132 |
this.parentBuffer = rel.getParentBufferNative().name().toStringMessage();
|
|
133 |
this.childBuffer = rel.getChildBufferNative().name().toStringMessage();
|
|
134 | 134 |
this.whereString = rel.getWhereString().toStringMessage(); |
135 | 135 |
this.active = rel._isActive(); |
136 | 136 |
this.parentId = rel.isParentIdRelation().booleanValue(); |
new/src/com/goldencode/p2j/persist/DynamicValidationHelper.java 2023-01-13 10:46:46 +0000 | ||
---|---|---|
151 | 151 |
* |
152 | 152 |
* @return {@link JastValidationExpr} instance representing the given validation expression. |
153 | 153 |
*/ |
154 |
public static JastValidationExpr parseValidationExpression(P2JQuery query,
|
|
154 |
public static JastValidationExpr parseValidationExpression(QueryWrapper query,
|
|
155 | 155 |
RecordBuffer validatedBuffer, |
156 | 156 |
String validatedProperty, |
157 | 157 |
String validateExpression) |
... | ... | |
162 | 162 |
List<Buffer> buffers = new ArrayList<>(numBuffers); |
163 | 163 |
for (int i = 1; i <= numBuffers; i++) |
164 | 164 |
{ |
165 |
buffers.add(query.bufferHandle(i).unwrapBuffer());
|
|
165 |
buffers.add(query.bufferHandleNative(i));
|
|
166 | 166 |
} |
167 | 167 |
|
168 | 168 |
JavaAst javaAst; |
new/src/com/goldencode/p2j/persist/QueryWrapper.java 2023-01-13 12:34:42 +0000 | ||
---|---|---|
655 | 655 |
{ |
656 | 656 |
createQuery(hQuery, (character) null); |
657 | 657 |
} |
658 | ||
659 |
/** |
|
660 |
* Dynamically creates a query in the specified widget pool. |
|
661 |
* |
|
662 |
* This method is the equivalent of <code>CREATE QUERY</code> from 4GL. |
|
663 |
* |
|
664 |
* @param widgetPool |
|
665 |
* The name of the widget pool that contains the dynamic query. <code>null</code> if |
|
666 |
* the unnamed pool must be used. |
|
667 |
* |
|
668 |
* @return the newly created query. |
|
669 |
*/ |
|
670 |
public static QueryWrapper createQueryNative(String widgetPool) |
|
671 |
{ |
|
672 |
// validate widget pool before anything else!!! |
|
673 |
if (!WidgetPool.validWidgetPool(widgetPool)) |
|
674 |
{ |
|
675 |
return null; |
|
676 |
} |
|
677 | ||
678 |
// create the query; use an empty string as its name |
|
679 |
QueryWrapper res = new QueryWrapper("", true, true); |
|
680 |
WidgetPool.addResourceNative(res, widgetPool); |
|
681 |
return res; |
|
682 |
} |
|
658 | 683 |
|
659 | 684 |
/** |
660 | 685 |
* Conversion of DYNAMIC attribute. Returns <code>true</code> if the buffer is dynamic. |
... | ... | |
3671 | 3696 |
public handle bufferHandle(int64 bufferSequenceNumber) |
3672 | 3697 |
{ |
3673 | 3698 |
int idx = bufferSequenceNumber.isUnknown() ? 0 : bufferSequenceNumber.intValue(); |
3674 |
|
|
3675 |
if (idx >= 1 && idx <= buffers.size()) |
|
3699 |
return new handle(bufferHandleNative(idx)); |
|
3700 |
} |
|
3701 | ||
3702 |
/** |
|
3703 |
* Conversion of GET-BUFFER-HANDLE() method (KW_GET_BUFH). |
|
3704 |
* |
|
3705 |
* Returns a particular buffer of a query object. |
|
3706 |
* |
|
3707 |
* @param bufferSequenceNumber |
|
3708 |
* buffer-sequence-number. An INTEGER that represents the sequence |
|
3709 |
* number of the desired buffer. |
|
3710 |
* |
|
3711 |
* @return buffer object |
|
3712 |
*/ |
|
3713 |
public Buffer bufferHandleNative(int bufferSequenceNumber) |
|
3714 |
{ |
|
3715 |
if (bufferSequenceNumber >= 1 && bufferSequenceNumber <= buffers.size()) |
|
3676 | 3716 |
{ |
3677 |
handle h = new handle(); |
|
3678 |
h.assign(buffers.get(idx - 1)); |
|
3679 |
return h; |
|
3717 |
return buffers.get(bufferSequenceNumber - 1); |
|
3680 | 3718 |
} |
3681 |
|
|
3719 | ||
3682 | 3720 |
String errMsg = "Query method argument must be the name of a query buffer or an integer " + |
3683 |
"from 1 to %d for query %s";
|
|
3721 |
"from 1 to %d for query %s"; |
|
3684 | 3722 |
errMsg = String.format(errMsg, numBuffers().intValue(), qname); |
3685 | 3723 | |
3686 | 3724 |
ErrorManager.recordOrShowError(7361, errMsg, false, false, false); |
3687 | 3725 | |
3688 |
return new handle();
|
|
3726 |
return null;
|
|
3689 | 3727 |
} |
3690 | 3728 | |
3691 | 3729 |
/** |
new/src/com/goldencode/p2j/persist/RecordBuffer.java 2023-01-13 11:07:29 +0000 | ||
---|---|---|
7206 | 7206 |
} |
7207 | 7207 |
|
7208 | 7208 |
TempTable table = getParentTable(); |
7209 |
Buffer buf = table.defaultBufferHandle().unwrapBuffer();
|
|
7209 |
Buffer buf = table.defaultBufferHandleNative();
|
|
7210 | 7210 |
return get((DataModelObject) buf); |
7211 | 7211 |
} |
7212 | 7212 |
|
... | ... | |
9760 | 9760 |
after.isAfterBuffer() && |
9761 | 9761 |
TempTableBuilder.asTempTable((Temporary) after).isTrackingChanges().getValue()) |
9762 | 9762 |
{ |
9763 |
handle hBefore = after.beforeBuffer();
|
|
9764 |
if (hBefore != null && !hBefore.isUnknown())
|
|
9763 |
BufferImpl before = after.beforeBufferNative();
|
|
9764 |
if (before != null)
|
|
9765 | 9765 |
{ |
9766 | 9766 |
// create new before record image, then update my before-rowid and row-state |
9767 |
BufferImpl before = (BufferImpl) hBefore.unwrapBuffer(); |
|
9768 | 9767 |
before.setUpBeforeBuffer(true); |
9769 | 9768 |
before.create(); |
9770 | 9769 |
RecordBuffer beforeBuf = before.buffer(); |
... | ... | |
11933 | 11932 |
after.isAfterBuffer() && |
11934 | 11933 |
TempTableBuilder.asTempTable((Temporary) after).isTrackingChanges().getValue()) |
11935 | 11934 |
{ |
11936 |
handle hBefore = after.beforeBuffer();
|
|
11937 |
if (!hBefore.isUnknown()) // should not be
|
|
11935 |
BufferImpl before = after.beforeBufferNative();
|
|
11936 |
if (before != null) // should not be
|
|
11938 | 11937 |
{ |
11939 | 11938 |
rowid beforeRowid = peerRowid(); |
11940 | 11939 |
if (beforeRowid.isUnknown()) |
11941 | 11940 |
{ |
11942 | 11941 |
// create new before record image, |
11943 |
BufferImpl before = (BufferImpl) hBefore.unwrapBuffer(); |
|
11944 | 11942 |
before.setUpBeforeBuffer(true); |
11945 | 11943 |
before.create(); |
11946 | 11944 |
before.bufferCopy(after); |
new/src/com/goldencode/p2j/persist/StaticTempTable.java 2023-01-13 10:21:10 +0000 | ||
---|---|---|
155 | 155 |
super.namespacePrefix(dmoInfo.namespacePrefix); |
156 | 156 |
} |
157 | 157 |
|
158 |
defaultBufferHandle = new handle(); |
|
159 |
defaultBufferHandle.assign(defaultBuffer); |
|
158 |
this.defaultBuffer = (BufferImpl) defaultBuffer; |
|
160 | 159 |
|
161 | 160 |
TableMapper.mapTemporaryTable(this); |
162 | 161 |
this.name.assign(dmoInfo.legacyTable); |
... | ... | |
1314 | 1313 |
*/ |