use of org.kie.workbench.common.screens.datamodeller.model.DataModelerError in project kie-wb-common by kiegroup.
the class DataModelerServiceImpl method updateJavaSource.
private Pair<String, List<DataModelerError>> updateJavaSource(String originalSource, DataObject dataObject, Map<String, String> renames, List<String> deletions, ClassLoader classLoader) throws Exception {
String newSource;
ClassTypeResolver classTypeResolver;
List<DataModelerError> errors = new ArrayList<DataModelerError>();
if (logger.isDebugEnabled()) {
logger.debug("Starting java source update for class: " + dataObject.getClassName());
}
if (logger.isDebugEnabled()) {
logger.debug("original source is: " + originalSource);
}
JavaType<?> javaType = Roaster.parse(originalSource);
if (javaType.isClass()) {
if (javaType.getSyntaxErrors() != null && !javaType.getSyntaxErrors().isEmpty()) {
// if a file has parsing errors it will be skipped.
errors.addAll(serviceHelper.toDataModelerError(javaType.getSyntaxErrors(), null));
newSource = originalSource;
} else {
JavaClassSource javaClassSource = (JavaClassSource) javaType;
classTypeResolver = DriverUtils.createClassTypeResolver(javaClassSource, classLoader);
updateJavaClassSource(dataObject, javaClassSource, renames, deletions, classTypeResolver);
newSource = javaClassSource.toString();
}
} else {
logger.debug("No Class definition was found for source: " + originalSource + ", original source won't be modified.");
newSource = originalSource;
}
if (logger.isDebugEnabled()) {
logger.debug("updated source is: " + newSource);
}
return new Pair<String, List<DataModelerError>>(newSource, errors);
}
use of org.kie.workbench.common.screens.datamodeller.model.DataModelerError in project kie-wb-common by kiegroup.
the class DataModelerServiceHelper method toDataModelerError.
public List<DataModelerError> toDataModelerError(final List<SyntaxError> syntaxErrors, final Path file) {
final List<DataModelerError> errors = new ArrayList<>();
DataModelerError error;
for (SyntaxError syntaxError : syntaxErrors) {
error = new DataModelerError(syntaxError.getDescription(), syntaxError.isError() ? Level.ERROR : Level.WARNING, Paths.convert(file));
error.setColumn(syntaxError.getColumn());
error.setLine(syntaxError.getLine());
errors.add(error);
}
return errors;
}
use of org.kie.workbench.common.screens.datamodeller.model.DataModelerError in project kie-wb-common by kiegroup.
the class DataModelerServiceHelper method toDataModelerError.
public List<DataModelerError> toDataModelerError(List<DriverError> errors) {
final List<DataModelerError> result = new ArrayList<>();
if (errors == null) {
return result;
}
for (DriverError error : errors) {
DataModelerError dataModelerError = new DataModelerError(error.getId(), error.getMessage(), Level.ERROR, error.getFile(), error.getLine(), error.getColumn());
result.add(dataModelerError);
}
return result;
}
use of org.kie.workbench.common.screens.datamodeller.model.DataModelerError in project kie-wb-common by kiegroup.
the class DataModelerScreenPresenter method publishSystemMessages.
private void publishSystemMessages(String messageType, boolean cleanExisting, List<DataModelerError> errors) {
PublishBatchMessagesEvent publishMessage = new PublishBatchMessagesEvent();
publishMessage.setCleanExisting(cleanExisting);
publishMessage.setMessageType(messageType);
publishMessage.setUserId((sessionInfo != null && sessionInfo.getIdentity() != null) ? sessionInfo.getIdentity().getIdentifier() : null);
publishMessage.setPlace(PublishBaseEvent.Place.TOP);
SystemMessage systemMessage;
for (DataModelerError error : errors) {
systemMessage = new SystemMessage();
systemMessage.setMessageType(messageType);
systemMessage.setId(error.getId());
systemMessage.setText(error.getMessage());
systemMessage.setPath(error.getFile());
systemMessage.setLevel(error.getLevel());
systemMessage.setLine(error.getLine());
systemMessage.setColumn(error.getColumn());
publishMessage.getMessagesToPublish().add(systemMessage);
}
if (workbenchContext.getActiveModule().isPresent()) {
publishMessage.setRootPath(workbenchContext.getActiveModule().get().getRootPath().toURI());
}
publishBatchMessagesEvent.fire(publishMessage);
}
use of org.kie.workbench.common.screens.datamodeller.model.DataModelerError in project kie-wb-common by kiegroup.
the class DataModelerScreenPresenterTestBase method createTestErrors.
protected List<DataModelerError> createTestErrors() {
List<DataModelerError> errors = new ArrayList<DataModelerError>();
errors.add(new DataModelerError(1, "error1", Level.ERROR, path, 1, 0));
errors.add(new DataModelerError(2, "error2", Level.ERROR, path, 2, 0));
errors.add(new DataModelerError(3, "error3", Level.ERROR, path, 3, 0));
return errors;
}
Aggregations