Commit d0e1aacb authored by Ngoc Quang Truong's avatar Ngoc Quang Truong
Browse files

#15 fix validation export csv not show error status

parent ab449f3d
......@@ -145,7 +145,7 @@ public class ValidationPart extends AbstractEmfFormsPart<IModelSession> {
try {
// create validation report
transformation = new SessionToValidationReportTransformation(
messages, versionService);
messages, versionService, enumTranslationService);
validationReport = transformation.transform(getModelSession());
final CacheService cacheService = ToolboxConfiguration.isDebugMode()
......@@ -166,7 +166,7 @@ public class ValidationPart extends AbstractEmfFormsPart<IModelSession> {
// Register nattable injector
tableView = new ValidationTableView(this, messages,
tableMenuService, enumTranslationService);
tableMenuService);
final Function<Composite, Control> func = innerParent -> {
final Composite composite = new Composite(innerParent,
......
......@@ -55,11 +55,11 @@ public class ValidationTablePart extends AbstractEmfFormsPart<IModelSession> {
throws ECPRendererException {
// create validation report
final SessionToValidationReportTransformation transformation = new SessionToValidationReportTransformation(
messages, versionService);
messages, versionService, enumTranslationService);
final ValidationReport validationReport = transformation
.transform(getModelSession());
final ValidationTableView tableView = new ValidationTableView(this,
messages, tableMenuService, enumTranslationService);
messages, tableMenuService);
tableView.create(parent, validationReport);
}
}
......@@ -26,6 +26,8 @@ import org.xml.sax.SAXParseException
import static extension org.eclipse.set.basis.extensions.IModelSessionExtensions.*
import static extension org.eclipse.set.feature.validation.utils.ObjectMetadataXMLReader.*
import java.util.List
import org.eclipse.set.core.services.enumtranslation.EnumTranslationService
import org.eclipse.emf.common.util.Enumerator
/**
* Transforms a {@link IModelSession} into a {@link ValidationReport}.
......@@ -41,10 +43,12 @@ class SessionToValidationReportTransformation {
val PlanProVersionService versionService
var ValidationReport report
val XMLNodeFinder xmlNodeFinder = new XMLNodeFinder();
val EnumTranslationService enumService
new(Messages messages, PlanProVersionService versionService) {
new(Messages messages, PlanProVersionService versionService, EnumTranslationService enumService) {
this.messages = messages
this.versionService = versionService
this.enumService = enumService
}
/**
......@@ -64,7 +68,6 @@ class SessionToValidationReportTransformation {
} else {
messages.NoMsg
}
report.valid = session?.validationResult?.outcome?.transform
report.xsdValid = session?.validationResult?.xsdOutcome?.transform
report.emfValid = session?.validationResult?.emfOutcome?.transform
......@@ -162,6 +165,7 @@ class SessionToValidationReportTransformation {
it.id = id
it.type = type
it.severity = severity
it.severityText = severity.translate
lineNumber = exception.line
message = exception.transformToMessage
val xmlNode = xmlNodeFinder.findNodeByLineNumber(lineNumber)
......@@ -184,6 +188,7 @@ class SessionToValidationReportTransformation {
it.id = id
it.type = type
it.severity = severity
it.severityText = severity.translate
lineNumber = exception.lineNumber
message = exception.transformToMessage
val xmlNode = xmlNodeFinder.findNodeByLineNumber(lineNumber)
......@@ -205,6 +210,7 @@ class SessionToValidationReportTransformation {
it.id = id
it.type = type
it.severity = severity
it.severityText = severity.translate
lineNumber = 0
message = exception.transformToMessage
objectArt = ""
......@@ -222,6 +228,7 @@ class SessionToValidationReportTransformation {
it.id = id
type = problem.type
severity = problem.severity
severityText = problem.severity.translate
lineNumber = problem.lineNumber
message = problem.message
objectArt = problem.objectArt
......@@ -239,6 +246,7 @@ class SessionToValidationReportTransformation {
it.id = id
type = errorType
severity = ValidationSeverity.SUCCESS
severityText = severity.translate
message = '''«errorType» validation'''
}
......@@ -275,6 +283,13 @@ class SessionToValidationReportTransformation {
val original = exception.message
return original.replaceFirst("cvc[^:]+: ", "")
}
private def String translate(Enumerator enumerator) {
if (enumerator === null) {
return null
}
return enumService.translate(enumerator).alternative
}
......
......@@ -11,26 +11,21 @@ package org.eclipse.set.feature.validation.table
import org.eclipse.set.model.validationreport.ValidationReport
import org.eclipse.set.utils.table.AbstractTableModelTransformator
import org.eclipse.set.utils.table.TMFactory
import org.eclipse.set.model.tablemodel.Table
import org.eclipse.set.core.services.enumtranslation.EnumTranslationService
import org.eclipse.emf.common.util.Enumerator
class ValidationReportTableTransformator extends AbstractTableModelTransformator<ValidationReport> {
ValidationTableColumns columns;
EnumTranslationService enumTranslationService
new(ValidationTableColumns columns, EnumTranslationService enumTranslationService) {
new(ValidationTableColumns columns) {
super()
this.columns = columns;
this.enumTranslationService = enumTranslationService;
}
override transformTableContent(ValidationReport report, TMFactory factory) {
for (problem : report.problems) {
val instance = factory.newTableRow(null, problem.id)
fill(instance, columns.RowIndex, problem, [problem.id.toString])
fill(instance, columns.Severity, problem, [severity.translate])
fill(instance, columns.Severity, problem, [severityText])
fill(instance, columns.ProblemType, problem, [type])
fillNumeric(instance, columns.LineNumber, problem, [lineNumber])
fill(instance, columns.ObjectType, problem, [objectArt])
......@@ -43,21 +38,4 @@ class ValidationReportTableTransformator extends AbstractTableModelTransformator
return factory.table
}
/**
* Translates the enum via the enum translation service.
*
* @param enumerator the enumerator
*
* @return the translation or <code>null</code>, if the enumerator is <code>null</code>
*/
def String translate(Enumerator enumerator) {
if (enumerator === null) {
return null
}
return enumTranslationService.translate(enumerator).alternative
}
override formatTableContent(Table table) {
}
}
......@@ -8,7 +8,6 @@
*/
package org.eclipse.set.feature.validation.table;
import org.eclipse.set.core.services.enumtranslation.EnumTranslationService;
import org.eclipse.set.feature.validation.Messages;
import org.eclipse.set.model.tablemodel.ColumnDescriptor;
import org.eclipse.set.model.validationreport.ValidationReport;
......@@ -29,24 +28,17 @@ public class ValidationTableTransformationService
private final Messages messages;
private final EnumTranslationService enumTranslationService;
/**
* @param messages
* the messages
* @param enumTranslationService
* the enum translation service
*/
public ValidationTableTransformationService(final Messages messages,
final EnumTranslationService enumTranslationService) {
public ValidationTableTransformationService(final Messages messages) {
this.messages = messages;
this.enumTranslationService = enumTranslationService;
}
@Override
public TableModelTransformator<ValidationReport> createTransformator() {
return new ValidationReportTableTransformator(columns,
enumTranslationService);
return new ValidationReportTableTransformator(columns);
}
@Override
......
......@@ -10,7 +10,6 @@ package org.eclipse.set.feature.validation.table;
import org.eclipse.nebula.widgets.nattable.NatTable;
import org.eclipse.set.basis.IModelSession;
import org.eclipse.set.core.services.enumtranslation.EnumTranslationService;
import org.eclipse.set.feature.validation.Messages;
import org.eclipse.set.model.tablemodel.Table;
import org.eclipse.set.model.validationreport.ValidationReport;
......@@ -30,7 +29,6 @@ public class ValidationTableView extends AbstractSortByColumnTables {
private final Messages messages;
private final BasePart<? extends IModelSession> part;
private NatTable natTable;
private final EnumTranslationService enumTranslationService;
private final TableMenuService tableMenuService;
......@@ -41,16 +39,11 @@ public class ValidationTableView extends AbstractSortByColumnTables {
* The messages
* @param tableMenuService
* The table menu service
* @param enumService
* The enum translation service
*/
public ValidationTableView(final BasePart<? extends IModelSession> part,
final Messages messages, final TableMenuService tableMenuService,
final EnumTranslationService enumTranslationService) {
final Messages messages, final TableMenuService tableMenuService) {
this.part = part;
this.messages = messages;
this.enumTranslationService = enumTranslationService;
this.tableMenuService = tableMenuService;
}
......@@ -66,7 +59,7 @@ public class ValidationTableView extends AbstractSortByColumnTables {
public Control create(final Composite parent,
final ValidationReport validationReport) {
final ValidationTableTransformationService service = new ValidationTableTransformationService(
messages, enumTranslationService);
messages);
final Table table = service.transform(validationReport);
this.createTableBodyData(table,
......@@ -86,7 +79,7 @@ public class ValidationTableView extends AbstractSortByColumnTables {
*/
public void updateView(final ValidationReport validationReport) {
final ValidationTableTransformationService service = new ValidationTableTransformationService(
messages, enumTranslationService);
messages);
bodyDataProvider.refresh(service.transform(validationReport));
natTable.refresh();
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment