Skip to content

Commit

Permalink
MID-7483 ninja options consolidation done
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed May 16, 2023
1 parent f46e5ac commit f2b0e9e
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
@Parameters(resourceBundle = "messages", commandDescriptionKey = "exportAudit")
public class ExportAuditOptions extends BaseAuditImportExportOptions implements BasicExportOptions {

public static final String P_OUTPUT = "-O";
public static final String P_OUTPUT = "-o";
public static final String P_OUTPUT_LONG = "--output";

public static final String P_OVERWRITE = "-ow";
public static final String P_OVERWRITE = "-O";
public static final String P_OVERWRITE_LONG = "--overwrite";

@Parameter(names = { P_OUTPUT, P_OUTPUT_LONG }, descriptionKey = "export.output")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.evolveum.midpoint.util.LocalizableMessage;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;

import org.apache.commons.lang3.BooleanUtils;
import org.apache.xml.serialize.LineSeparator;

/**
Expand Down Expand Up @@ -77,7 +78,7 @@ protected void init() {
}
}

if (options.isCreateReport()) {
if (BooleanUtils.isTrue(options.isCreateReport())) {
CSVFormat csv = createCsvFormat();

try {
Expand Down Expand Up @@ -113,7 +114,7 @@ protected void write(Writer writer, ObjectType object) throws IOException {
writeValidationItem(writer, prismObject, validationItem);
}

if (options.isCreateReport()) {
if (BooleanUtils.isTrue(options.isCreateReport())) {
for (ValidationItem item : validationResult.getItems()) {
reportWriter.printRecord(createReportRecord(item, prismObject));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public class BaseImportExportOptions {
public static final String P_RAW = "-r";
public static final String P_RAW_LONG = "--raw";

public static final String P_OID = "-o";
public static final String P_OID_LONG = "--oid";

public static final String P_TYPE = "-t";
Expand All @@ -41,7 +40,7 @@ public class BaseImportExportOptions {
@Parameter(names = {P_RAW, P_RAW_LONG}, descriptionKey = "baseImportExport.raw")
private boolean raw;

@Parameter(names = {P_OID, P_OID_LONG}, descriptionKey = "baseImportExport.oid")
@Parameter(names = {P_OID_LONG}, descriptionKey = "baseImportExport.oid")
private String oid;

@Parameter(names = {P_TYPE, P_TYPE_LONG}, descriptionKey = "base.type",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
import java.io.File;

public interface BasicExportOptions {

File getOutput();

boolean isOverwrite();

boolean isZip();
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
@Parameters(resourceBundle = "messages", commandDescriptionKey = "export")
public class ExportOptions extends BaseImportExportOptions implements BasicExportOptions {

public static final String P_OUTPUT = "-O";
public static final String P_OUTPUT = "-o";
public static final String P_OUTPUT_LONG = "--output";

public static final String P_OVERWRITE = "-ow";
public static final String P_OVERWRITE = "-O";
public static final String P_OVERWRITE_LONG = "--overwrite";

// TODO not supported yet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public class ImportOptions extends BaseImportExportOptions implements BasicImpor

public static final String P_CONTINUE_ON_INPUT_ERROR_LONG = "--continueOnInputError";


@Parameter(names = { P_INPUT, P_INPUT_LONG }, descriptionKey = "import.input")
private File input;

Expand All @@ -39,7 +38,7 @@ public class ImportOptions extends BaseImportExportOptions implements BasicImpor
descriptionKey = "import.allowUnencryptedValues")
private boolean allowUnencryptedValues;

@Parameter(names = { P_CONTINUE_ON_INPUT_ERROR_LONG }, descriptionKey = "import.continueOnInputError")
@Parameter(names = { P_CONTINUE_ON_INPUT_ERROR_LONG }, descriptionKey = "import.continueOnInputError")
private boolean continueOnInputError;

@Override
Expand All @@ -60,5 +59,4 @@ public boolean isContinueOnInputError() {
return continueOnInputError;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ public class VerifyOptions extends ExportOptions {
@Parameter(names = {P_WARN, P_WARN_LONG}, descriptionKey = "verify.warn")
private String warn;

@Parameter(names = {P_CREATE_REPORT}) // todo description, etc
private boolean createReport;
@Parameter(names = {P_CREATE_REPORT}, descriptionKey = "verify.createReport")
private Boolean createReport;

public String getWarn() {
return warn;
}

public boolean isCreateReport() {
public Boolean isCreateReport() {
return createReport;
}
}
2 changes: 1 addition & 1 deletion tools/ninja/src/main/resources/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@ Without NFKD processing the whole character will be removed.
base.psn.trimWhitespace=PolyString normalizer trim whitespace
base.psn.lowercase=PolyString normalizer lowercase
upgrade=Run midPoint upgrade procedure

verify.createReport=Create CSV report from verification process

0 comments on commit f2b0e9e

Please sign in to comment.