@Override
public List<ExternalIoStage> emitEpilogue(IoContext context) throws IOException {
ModelFactory f = getEnvironment().getModelFactory();
NamingClassEmitter namingEmitter = new NamingClassEmitter(getEnvironment(), MODULE_NAME);
OrderingClassEmitter orderingEmitter = new OrderingClassEmitter(getEnvironment(), MODULE_NAME);
List<Slot> slots = Lists.create();
for (Output output : context.getOutputs()) {
DirectFileOutputDescription desc = extract(output.getDescription());
DataClass dataType = getEnvironment().getDataClasses().load(desc.getModelType());
List<CompiledResourcePattern> namingInfo =
OutputPattern.compileResourcePattern(desc.getResourcePattern(), dataType);
Set<OutputPattern.SourceKind> kinds = pickSourceKinds(namingInfo);
if (kinds.contains(OutputPattern.SourceKind.ENVIRONMENT)) {
assert kinds.contains(OutputPattern.SourceKind.PROPERTY) == false;
assert kinds.contains(OutputPattern.SourceKind.RANDOM) == false;
assert desc.getOrder().isEmpty();
String outputName = output.getDescription().getName();
Slot slot = new Slot(
outputName,
output.getSources(),
Models.toName(f, desc.getModelType().getName()),
desc.getBasePath(),
desc.getResourcePattern(),
Models.toName(f, desc.getFormat().getName()),
null,
null,
desc.getDeletePatterns());
slots.add(slot);
} else {
List<CompiledOrder> orderingInfo = OutputPattern.compileOrder(desc.getOrder(), dataType);
String outputName = output.getDescription().getName();
Name naming = namingEmitter.emit(outputName, slots.size() + 1, dataType, namingInfo);
Name ordering = orderingEmitter.emit(outputName, slots.size() + 1, dataType, orderingInfo);
Slot slot = new Slot(
outputName,
output.getSources(),
Models.toName(f, desc.getModelType().getName()),
desc.getBasePath(),