mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-20 06:00:44 +00:00
Initial checkin of API module
This commit is contained in:
@ -43,6 +43,7 @@ public class ProcessSummaryLine implements ProcessSummaryLineInterface
|
||||
private String pluralFutureMessage;
|
||||
private String singularPastMessage;
|
||||
private String pluralPastMessage;
|
||||
private String messageSuffix;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// using ArrayList, because we need to be Serializable, and List is not //
|
||||
@ -394,11 +395,13 @@ public class ProcessSummaryLine implements ProcessSummaryLineInterface
|
||||
{
|
||||
if(count.equals(1))
|
||||
{
|
||||
setMessage(isPast ? getSingularPastMessage() : getSingularFutureMessage());
|
||||
setMessage((isPast ? getSingularPastMessage() : getSingularFutureMessage())
|
||||
+ (messageSuffix == null ? "" : messageSuffix));
|
||||
}
|
||||
else
|
||||
{
|
||||
setMessage(isPast ? getPluralPastMessage() : getPluralFutureMessage());
|
||||
setMessage((isPast ? getPluralPastMessage() : getPluralFutureMessage())
|
||||
+ (messageSuffix == null ? "" : messageSuffix));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -417,4 +420,38 @@ public class ProcessSummaryLine implements ProcessSummaryLineInterface
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for messageSuffix
|
||||
**
|
||||
*******************************************************************************/
|
||||
public String getMessageSuffix()
|
||||
{
|
||||
return messageSuffix;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for messageSuffix
|
||||
**
|
||||
*******************************************************************************/
|
||||
public void setMessageSuffix(String messageSuffix)
|
||||
{
|
||||
this.messageSuffix = messageSuffix;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Fluent setter for messageSuffix
|
||||
**
|
||||
*******************************************************************************/
|
||||
public ProcessSummaryLine withMessageSuffix(String messageSuffix)
|
||||
{
|
||||
this.messageSuffix = messageSuffix;
|
||||
return (this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ package com.kingsrook.qqq.backend.core.model.actions.processes;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import com.kingsrook.qqq.backend.core.model.actions.AbstractActionOutput;
|
||||
@ -241,4 +242,18 @@ public class RunBackendStepOutput extends AbstractActionOutput implements Serial
|
||||
return (ValueUtils.getValueAsBigDecimal(getValue(fieldName)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
public void addRecord(QRecord record)
|
||||
{
|
||||
if(this.processState.getRecords() == null)
|
||||
{
|
||||
this.processState.setRecords(new ArrayList<>());
|
||||
}
|
||||
this.processState.getRecords().add(record);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,6 +22,7 @@
|
||||
package com.kingsrook.qqq.backend.core.model.actions.tables.insert;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import com.kingsrook.qqq.backend.core.model.actions.AbstractActionOutput;
|
||||
import com.kingsrook.qqq.backend.core.model.data.QRecord;
|
||||
@ -54,4 +55,19 @@ public class InsertOutput extends AbstractActionOutput
|
||||
{
|
||||
this.records = records;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
public void addRecord(QRecord record)
|
||||
{
|
||||
if(this.records == null)
|
||||
{
|
||||
this.records = new ArrayList<>();
|
||||
}
|
||||
this.records.add(record);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -75,7 +75,8 @@ public class QBackendModuleDispatcher
|
||||
"com.kingsrook.qqq.backend.core.modules.backend.implementations.memory.MemoryBackendModule",
|
||||
"com.kingsrook.qqq.backend.module.rdbms.RDBMSBackendModule",
|
||||
"com.kingsrook.qqq.backend.module.filesystem.local.FilesystemBackendModule",
|
||||
"com.kingsrook.qqq.backend.module.filesystem.s3.S3BackendModule"
|
||||
"com.kingsrook.qqq.backend.module.filesystem.s3.S3BackendModule",
|
||||
"com.kingsrook.qqq.backend.module.api.APIBackendModule"
|
||||
};
|
||||
|
||||
for(String moduleClassName : moduleClassNames)
|
||||
|
@ -71,4 +71,18 @@ public class StreamedBackendStepOutput extends RunBackendStepOutput
|
||||
return (outputRecords);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
@Override
|
||||
public void addRecord(QRecord record)
|
||||
{
|
||||
if(this.outputRecords == null)
|
||||
{
|
||||
this.outputRecords = new ArrayList<>();
|
||||
}
|
||||
this.outputRecords.add(record);
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,7 @@
|
||||
package com.kingsrook.qqq.backend.core.utils;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
@ -29,6 +30,7 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import com.kingsrook.qqq.backend.core.model.data.QRecord;
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
@ -422,4 +424,57 @@ public class CollectionUtils
|
||||
}
|
||||
return (list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Returns the input collection, unless it was null - in which case a new array list is returned.
|
||||
**
|
||||
** Meant to help avoid null checks on foreach loops.
|
||||
*******************************************************************************/
|
||||
public static <T> Collection<T> nonNullCollection(Collection<T> list)
|
||||
{
|
||||
if(list == null)
|
||||
{
|
||||
return (new ArrayList<>());
|
||||
}
|
||||
return (list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Convert a collection of QRecords to a map, from one field's values out of
|
||||
** those records, to another field's value from those records
|
||||
*******************************************************************************/
|
||||
public static Map<Serializable, Serializable> recordsToMap(Collection<QRecord> records, String keyFieldName, String valueFieldName)
|
||||
{
|
||||
Map<Serializable, Serializable> rs = new HashMap<>();
|
||||
|
||||
for(QRecord record : nonNullCollection(records))
|
||||
{
|
||||
rs.put(record.getValue(keyFieldName), record.getValue(valueFieldName));
|
||||
}
|
||||
|
||||
return (rs);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Convert a collection of QRecords to a map, from one field's values out of
|
||||
** those records, to the records themselves.
|
||||
*******************************************************************************/
|
||||
public static Map<Serializable, QRecord> recordsToMap(Collection<QRecord> records, String keyFieldName)
|
||||
{
|
||||
Map<Serializable, QRecord> rs = new HashMap<>();
|
||||
|
||||
for(QRecord record : nonNullCollection(records))
|
||||
{
|
||||
rs.put(record.getValue(keyFieldName), record);
|
||||
}
|
||||
|
||||
return (rs);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user