001/* 002 * (C) Copyright 2012 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Thomas Roger 018 */ 019 020package org.nuxeo.ecm.csv.core; 021 022import java.util.List; 023 024/** 025 * @author <a href="mailto:troger@nuxeo.com">Thomas Roger</a> 026 * @since 5.7 027 */ 028public class CSVImportResult { 029 030 protected final long totalLineCount; 031 032 protected final long successLineCount; 033 034 protected final long skippedLineCount; 035 036 protected final long errorLineCount; 037 038 public static final CSVImportResult fromImportLogs(List<CSVImportLog> importLogs) { 039 long totalLineCount = importLogs.size(); 040 long successLineCount = 0; 041 long skippedLineCount = 0; 042 long errorLineCount = 0; 043 for (CSVImportLog importLog : importLogs) { 044 if (importLog.isSuccess()) { 045 successLineCount++; 046 } else if (importLog.isSkipped()) { 047 skippedLineCount++; 048 } else if (importLog.isError()) { 049 errorLineCount++; 050 } 051 } 052 return new CSVImportResult(totalLineCount, successLineCount, skippedLineCount, errorLineCount); 053 } 054 055 public CSVImportResult(long totalLineCount, long successLineCount, long skippedLineCount, long errorLineCount) { 056 this.totalLineCount = totalLineCount; 057 this.successLineCount = successLineCount; 058 this.skippedLineCount = skippedLineCount; 059 this.errorLineCount = errorLineCount; 060 } 061 062 public long getTotalLineCount() { 063 return totalLineCount; 064 } 065 066 public long getSuccessLineCount() { 067 return successLineCount; 068 } 069 070 public long getSkippedLineCount() { 071 return skippedLineCount; 072 } 073 074 public long getErrorLineCount() { 075 return errorLineCount; 076 } 077}