Skip to content

Instantly share code, notes, and snippets.

@simonwoo
Last active October 13, 2015 08:56
Show Gist options
  • Select an option

  • Save simonwoo/28009c9d9a86db8f0225 to your computer and use it in GitHub Desktop.

Select an option

Save simonwoo/28009c9d9a86db8f0225 to your computer and use it in GitHub Desktop.
if (failedRows.isEmpty()) {

                createAndStoreMessage(store, version, CellTraceLevel.INFO,
                        "Bulk data import successful.",
                        persistenceManager);

            } else {

                final String titleMessage;
                final String detailedMessage;
                final String warnings = detailedValidationContext.buildMessage("\n", " - ", false);

                if (failedRows.size() < MAX_ERRORS_NUMBER) {

                    titleMessage = String.format("succeeded with warnings: %s lines were not imported",
                            failedRows.size());
                    detailedMessage = String.format("The import succeeded with warnings:\n %s",
                            warnings);

                } else {

                    Integer lineNb = failedRows.get(failedRows.size() - 1);

                    titleMessage = String.format("stopped at line %s because too many errors were detected", lineNb);

                    // create error generator
                    detailedMessage = String.format(
                            "The import stopped at line %s because too many errors were detected:\n %s",
                            lineNb,
                            warnings);
                }

                taskService.putInTaskResult("messages", ImmutableList.of(new ServiceValidationMessage(
                        titleMessage,
                        ServiceValidationType.WARNING)));

                createAndStoreMessage(store, version, CellTraceLevel.WARNING, detailedMessage, persistenceManager);
            }
 var link = 'See <a href="/stores/{cellId}/versions/{nb}/messages#traces">Traces</a> for details'
                .format({
                  cellId: cellContext.cellId,
                  nb: cellContext.versionMajorNumber
                });

              _.each(importMessages, function (importMessage) {

                importMessage.message = '{job} {msg}. {link}.'
                  .format({
                    job: jobName,
                    msg: importMessage.message,
                    link: link
                  });
              })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment