woltlab-compiler
Version:
A compiler for WoltLab-Package Archives and WoltLab-Package Components
65 lines • 2.68 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const util_1 = require("util");
const XMLEditor_1 = require("../../Serialization/XMLEditor");
const NamedObjectDeletionFileCompiler_1 = require("../NamedObjectDeletionFileCompiler");
/**
* Provides the functionality to compile cron-job files.
*/
class CronJobFileCompiler extends NamedObjectDeletionFileCompiler_1.NamedObjectDeletionFileCompiler {
/**
* Initializes a new instance of the `CronJobFileCompiler` class.
*
* @param item
* The item to compile.
*/
constructor(item) {
super(item);
}
/**
* @inheritdoc
*/
get SchemaLocation() {
return "https://www.woltlab.com/XSD/tornado/cronjob.xsd";
}
/**
* @inheritdoc
*/
get ObjectTagName() {
return "cronjob";
}
/**
* @inheritdoc
*/
CreateImport() {
let editor = new XMLEditor_1.XMLEditor(super.CreateImport());
for (let cronJob of this.Item.CronJobs) {
editor.AddElement("cronjob", (cronJobEditor) => {
if (!util_1.isNullOrUndefined(cronJob.Name)) {
cronJobEditor.SetAttribute("name", cronJob.Name);
}
for (let locale of cronJob.Description.GetLocales()) {
cronJobEditor.AddTextElement("description", cronJob.Description.Data[locale], (description) => {
if (locale !== "inv") {
description.SetAttribute("language", locale);
}
});
}
cronJobEditor.AddTextElement("classname", cronJob.ClassName);
cronJobEditor.AddTextElement("canbeedited", cronJob.AllowEdit ? "1" : "0");
cronJobEditor.AddTextElement("canbedisabled", cronJob.AllowDisable ? "1" : "0");
if (cronJob.Options.length > 0) {
cronJobEditor.AddTextElement("options", cronJob.Options.join(","));
}
cronJobEditor.AddTextElement("startminute", cronJob.Period.Minute);
cronJobEditor.AddTextElement("starthour", cronJob.Period.Hour);
cronJobEditor.AddTextElement("startdom", cronJob.Period.DayOfMonth);
cronJobEditor.AddTextElement("startmonth", cronJob.Period.Month);
cronJobEditor.AddTextElement("startdow", cronJob.Period.DayOfWeek);
});
}
return editor.Element;
}
}
exports.CronJobFileCompiler = CronJobFileCompiler;
//# sourceMappingURL=CronJobFileCompiler.js.map