forked from blcham/record-manager
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from akaene/main
Records import
- Loading branch information
Showing
15 changed files
with
544 additions
and
16 deletions.
There are no files selected for viewing
76 changes: 76 additions & 0 deletions
76
src/main/java/cz/cvut/kbss/study/dto/RecordImportResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package cz.cvut.kbss.study.dto; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* Represents the result of importing records to this instance. | ||
*/ | ||
public class RecordImportResult { | ||
|
||
/** | ||
* Total number of processed records. | ||
*/ | ||
private int totalCount; | ||
|
||
/** | ||
* Number of successfully imported records. | ||
*/ | ||
private int importedCount; | ||
|
||
/** | ||
* Errors that occurred during import. | ||
*/ | ||
private List<String> errors; | ||
|
||
public RecordImportResult() { | ||
} | ||
|
||
public RecordImportResult(int totalCount) { | ||
this.totalCount = totalCount; | ||
} | ||
|
||
public int getTotalCount() { | ||
return totalCount; | ||
} | ||
|
||
public void setTotalCount(int totalCount) { | ||
this.totalCount = totalCount; | ||
} | ||
|
||
public int getImportedCount() { | ||
return importedCount; | ||
} | ||
|
||
public void setImportedCount(int importedCount) { | ||
this.importedCount = importedCount; | ||
} | ||
|
||
public void incrementImportedCount() { | ||
this.importedCount++; | ||
} | ||
|
||
public List<String> getErrors() { | ||
return errors; | ||
} | ||
|
||
public void setErrors(List<String> errors) { | ||
this.errors = errors; | ||
} | ||
|
||
public void addError(String error) { | ||
if (this.errors == null) { | ||
this.errors = new ArrayList<>(); | ||
} | ||
errors.add(error); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "RecordImportResult{" + | ||
"totalCount=" + totalCount + | ||
", importedCount=" + importedCount + | ||
(errors != null ? ", errors=" + errors : "") + | ||
'}'; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/cz/cvut/kbss/study/exception/RecordAuthorNotFoundException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package cz.cvut.kbss.study.exception; | ||
|
||
/** | ||
* Indicates that the application is attempting to import a record with a nonexistent author. | ||
*/ | ||
public class RecordAuthorNotFoundException extends RecordManagerException { | ||
|
||
public RecordAuthorNotFoundException(String message) { | ||
super(message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.