Skip to content

Commit

Permalink
clean ADPInstanceDAO api
Browse files Browse the repository at this point in the history
  • Loading branch information
teosarca committed Jan 28, 2019
1 parent eb3590d commit a9e8ec9
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 29 deletions.
Expand Up @@ -1582,7 +1582,7 @@ public int createSelection(@NonNull final PInstanceId pinstanceId)
public PInstanceId createSelection()
{
// Create new AD_PInstance_ID for our selection
final PInstanceId newSelectionId = Services.get(IADPInstanceDAO.class).createPInstanceId();
final PInstanceId newSelectionId = Services.get(IADPInstanceDAO.class).createSelectionId();

// Populate the selection
final int count = createSelection(newSelectionId);
Expand Down Expand Up @@ -1822,7 +1822,7 @@ <ToModelType> QueryInsertExecutorResult executeInsert(
final String sql;
if (queryInserter.isCreateSelectionOfInsertedRows())
{
insertSelectionId = Services.get(IADPInstanceDAO.class).createPInstanceId();
insertSelectionId = Services.get(IADPInstanceDAO.class).createSelectionId();

final String toKeyColumnName = queryInserter.getToKeyColumnName();
sql = new StringBuilder()
Expand Down
Expand Up @@ -2247,7 +2247,7 @@ public static void createT_Selection(@NonNull final PInstanceId pinstanceId, Ite
*/
public static PInstanceId createT_Selection(Iterable<Integer> selection, String trxName)
{
final PInstanceId pinstanceId = Services.get(IADPInstanceDAO.class).createPInstanceId();
final PInstanceId pinstanceId = Services.get(IADPInstanceDAO.class).createSelectionId();
createT_Selection(pinstanceId, selection, trxName);
return pinstanceId;
}
Expand Down
Expand Up @@ -84,19 +84,19 @@ public interface IADPInstanceDAO extends ISingletonService
List<ProcessInfoLog> retrieveProcessInfoLogs(PInstanceId pinstanceId);

/**
* Creates a new AD_PInstance_ID.
* Creates a new selection ID (AD_PInstance_ID).
*
* IMPORTANT: <b>this method is NOT creating an {@link I_AD_PInstance} record.</b>
* If you want to create an {@link I_AD_PInstance}, please use {@link #createAD_PInstance(AdProcessId, int, int)}.
* If you want to create an {@link I_AD_PInstance}, please use {@link #createAD_PInstance(AdProcessId)}.
*
* @return new AD_PInstance_ID
*/
PInstanceId createPInstanceId();
PInstanceId createSelectionId();

/**
* Creates and saves a new AD_PInstance.
*/
I_AD_PInstance createAD_PInstance(AdProcessId adProcessId, int AD_Table_ID, int recordId);
I_AD_PInstance createAD_PInstance(AdProcessId adProcessId);

/**
* @return process instance; never returns null
Expand Down
Expand Up @@ -558,28 +558,21 @@ public void saveProcessInfoOnly(final ProcessInfo pi)
}

@Override
public PInstanceId createPInstanceId()
public PInstanceId createSelectionId()
{
final String trxName = ITrx.TRXNAME_None;
final int adPInstanceId = DB.getNextID(Env.getCtx(), I_AD_PInstance.Table_Name, trxName);
return PInstanceId.ofRepoId(adPInstanceId);
}

@Override
public I_AD_PInstance createAD_PInstance(@NonNull final AdProcessId adProcessId, final int AD_Table_ID, final int recordId)
public I_AD_PInstance createAD_PInstance(@NonNull final AdProcessId adProcessId)
{
final I_AD_PInstance adPInstance = newInstanceOutOfTrx(I_AD_PInstance.class);
adPInstance.setAD_Process_ID(adProcessId.getRepoId());
if (AD_Table_ID > 0)
{
adPInstance.setAD_Table_ID(AD_Table_ID);
adPInstance.setRecord_ID(recordId);
}
else
{
adPInstance.setAD_Table(null);
adPInstance.setRecord_ID(0); // mandatory
}

adPInstance.setAD_Table(null);
adPInstance.setRecord_ID(0); // mandatory

final Properties ctx = Env.getCtx();
adPInstance.setAD_User_ID(Env.getAD_User_ID(ctx));
Expand Down
Expand Up @@ -35,7 +35,7 @@
public class PlainADPInstanceDAO extends ADPInstanceDAO
{
@Override
public PInstanceId createPInstanceId()
public PInstanceId createSelectionId()
{
return PInstanceId.ofRepoId(POJOLookupMap.get().nextId(I_AD_PInstance.Table_Name));
}
Expand Down
Expand Up @@ -1093,7 +1093,7 @@ public void createSelection(@NonNull final PInstanceId selectionId, final Collec

private PInstanceId createSelectionPInstanceId()
{
return Services.get(IADPInstanceDAO.class).createPInstanceId();
return Services.get(IADPInstanceDAO.class).createSelectionId();
}

public PInstanceId createSelection(final Collection<Integer> selection)
Expand Down
Expand Up @@ -240,9 +240,7 @@ private <T extends JavaProcess> ProcessInfo createProcessInfo(final Class<T> pro

// Create the AD_PInstance record
final AdProcessId adProcessId = createProcess(processClass);
final int AD_Table_ID = 0;
final int recordId = 0;
final I_AD_PInstance pinstance = pinstancesRepo.createAD_PInstance(adProcessId, AD_Table_ID, recordId);
final I_AD_PInstance pinstance = pinstancesRepo.createAD_PInstance(adProcessId);

//
// Create ProcessInfo descriptor
Expand Down
Expand Up @@ -409,7 +409,7 @@ private final synchronized PInstanceId getADPInstanceId()
PInstanceId pinstanceId = _pinstanceId;
if (pinstanceId == null)
{
_pinstanceId = pinstanceId = Services.get(IADPInstanceDAO.class).createPInstanceId();
_pinstanceId = pinstanceId = Services.get(IADPInstanceDAO.class).createSelectionId();
}
return pinstanceId;
}
Expand Down
Expand Up @@ -179,7 +179,7 @@ private byte[] createSummaryPage(final I_C_Print_Job_Instructions jobInstruction
final Properties ctx = InterfaceWrapperHelper.getCtx(jobInstructions);
final Language language = Services.get(ILanguageBL.class).getOrgLanguage(ctx, jobInstructions.getAD_Org_ID());

final I_AD_PInstance pinstance = Services.get(IADPInstanceDAO.class).createAD_PInstance(SummaryPdfPrinting_AD_Process_ID, 0, 0);
final I_AD_PInstance pinstance = Services.get(IADPInstanceDAO.class).createAD_PInstance(SummaryPdfPrinting_AD_Process_ID);
pinstance.setIsProcessing(true);
InterfaceWrapperHelper.save(pinstance);

Expand Down
Expand Up @@ -119,7 +119,7 @@ public void exportFinished(IExporter exporter)

private I_AD_PInstance createPInstance()
{
final I_AD_PInstance pinstance = Services.get(IADPInstanceDAO.class).createAD_PInstance(adProcessId, 0, 0);
final I_AD_PInstance pinstance = Services.get(IADPInstanceDAO.class).createAD_PInstance(adProcessId);
pinstance.setIsProcessing(true);
InterfaceWrapperHelper.save(pinstance);

Expand Down
Expand Up @@ -75,7 +75,7 @@ public Result processWorkPackage(final I_C_Queue_WorkPackage workpackage, final
final Properties ctx = InterfaceWrapperHelper.getCtx(workpackage);

final int adUserId = workpackage.getCreatedBy();
final PInstanceId pinstanceId = Services.get(IADPInstanceDAO.class).createPInstanceId();
final PInstanceId pinstanceId = Services.get(IADPInstanceDAO.class).createSelectionId();

final boolean updateOnlyLocked = true; // don't create missing schedules; for that we have CreateMissingShipmentSchedulesWorkpackageProcessor
final int updatedCount = shipmentScheduleUpdater.updateShipmentSchedule(ctx, adUserId, pinstanceId, updateOnlyLocked);
Expand Down
Expand Up @@ -847,7 +847,7 @@ public final Iterator<I_C_Invoice_Candidate> fetchInvalidInvoiceCandidates(
@Override
public InvoiceCandRecomputeTag generateNewRecomputeTag()
{
final PInstanceId pinstanceId = Services.get(IADPInstanceDAO.class).createPInstanceId();
final PInstanceId pinstanceId = Services.get(IADPInstanceDAO.class).createSelectionId();
return InvoiceCandRecomputeTag.ofPInstanceId(pinstanceId);
}

Expand Down

0 comments on commit a9e8ec9

Please sign in to comment.