Skip to content

Commit

Permalink
Add Part Number Check
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruno De Bel authored and Bruno De Bel committed Feb 9, 2018
1 parent 32a674b commit b2ce37e
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 12 deletions.
1 change: 1 addition & 0 deletions project/inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ void inventoryMapping::setCurrentInventoryValue(std::string field, std::string v
if ( field.compare("printer")==0 ) currentInventory->printer=value;
if ( field.compare("yearnumber")==0 ) currentInventory->yearnumber=value;
if ( field.compare("issuenumber")==0 ) currentInventory->issuenumber=value;
if ( field.compare("partNumber")==0 ) currentInventory->partNumber=value;

if ( field.compare("author")==0 ) currentInventory->author=value;

Expand Down
3 changes: 3 additions & 0 deletions project/inventory.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ class inventory{
std::string formaldate;
std::string type;
std::string pages;

std::string partNumber; // from mets file but needed by YearNumber issueNumber

std::string uniquebuildkey;
std::map<std::string,std::string> languageTerm;
std::string toString(std::string name);
Expand Down
2 changes: 1 addition & 1 deletion project/metsparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ class StateParsermodStateTitleInfoInventory:public StateParsermodState{
//std::cerr << "Only Ones :"<< ++i << std::endl;
map["title"]= new StateParsermodStateInventory("title");
map["nonSort"]= new StateTitleState(" ");
map["partNumber"]= new StateDoNothingState();
map["partNumber"]= new StateParsermodStateInventory("partNumber");
}
} onlyOnes (map);

Expand Down
5 changes: 4 additions & 1 deletion project/sql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ void database::dberror(std::string sql){
bool database::getInventory(std::string _sysnum, inventory& _inventory){
bool ret = false;
static std::string sql = "SELECT UNIQUEBUILDKEY,AUTHOR,PAPERID,"
" LANGUAGES,FORMALDATE,TYPE,TITLE,TITLECOLLECTION,PAGES"
" LANGUAGES,FORMALDATE,TYPE,TITLE,TITLECOLLECTION,CALLNUMBER,ISSUENUMBER,YEARNUMBER,PAGES,"
" CHECKED"
" from INVENTORY where UNIQUEBUILDKEY=?";

Expand Down Expand Up @@ -221,6 +221,9 @@ bool database::getInventory(std::string _sysnum, inventory& _inventory){
_inventory.type = safe_sqlite3_column_text(pStmt, col++);
_inventory.title = safe_sqlite3_column_text(pStmt, col++);
_inventory.titlecollection = safe_sqlite3_column_text(pStmt, col++);
_inventory.callnumber = safe_sqlite3_column_text(pStmt, col++);
_inventory.issuenumber = safe_sqlite3_column_text(pStmt, col++);
_inventory.yearnumber = safe_sqlite3_column_text(pStmt, col++);
_inventory.pages = safe_sqlite3_column_text(pStmt, col++);

_inventory.checked = sqlite3_column_int(pStmt, col++);
Expand Down
52 changes: 42 additions & 10 deletions project/verifyBook.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "verifybook.h"
#include <iostream>
#include "inventory.h"
#include <sstream>



Expand Down Expand Up @@ -32,22 +33,26 @@ void verifyBook::check(int check,metsparserContext& context){
hError -> getError(cat_bookinventoryTitle,"METS","DMDSEC MODSMD_COLLECTION", "wrong title collection:" + context.inventory.inventoryMODSMD_COLLECTION.title +" against :"+ invent.titlecollection ,context.currentMetsFile,context.inventory.inventoryMODSMD_COLLECTION.title);
}

/* //TODO rebuild all those test
title = buildTitle( context.inventory.inventoryMODSMD_PRINT);
if ( invent.BIBREC_245a.compare(title)) {
hError -> getError(cat_bookinventoryTitle,"METS","DMDSEC MODSMD_PRINT", "wrong title:" + context.inventory.inventoryMODSMD_PRINT.BIBREC_245a +" against :"+ invent.BIBREC_245a,context.currentMetsFile,context.inventory.inventoryMODSMD_PRINT.BIBREC_245a);
if ( invent.publisher.compare(context.inventory.inventoryMODSMD_PRINT.publisher)) {
hError -> getError(cat_bookinventoryTitle,"METS","DMDSEC MODSMD_PRINT", "wrong publisher:" + context.inventory.inventoryMODSMD_PRINT.publisher +" against :"+ invent.publisher ,context.currentMetsFile,context.inventory.inventoryMODSMD_PRINT.publisher);
}

if ( invent.printer.compare(context.inventory.inventoryMODSMD_PRINT.printer)) {
hError -> getError(cat_bookinventoryTitle,"METS","DMDSEC MODSMD_PRINT", "wrong printer:" + context.inventory.inventoryMODSMD_PRINT.printer +" against :"+ invent.printer ,context.currentMetsFile,context.inventory.inventoryMODSMD_PRINT.printer);
}

if ( invent.BIBREC_100a.compare(context.inventory.inventoryMODSMD_COLLECTION.BIBREC_100a)) {
hError -> getError(cat_bookinventoryData,"METS","DMDSEC MODSMD_COLLECTION", "wrong BIBREC_100a:" + context.inventory.inventoryMODSMD_COLLECTION.BIBREC_100a +" against :"+ invent.BIBREC_100a,context.currentMetsFile,context.inventory.inventoryMODSMD_COLLECTION.BIBREC_100a);

if ( invent.callnumber.compare(context.inventory.inventoryMODSMD_PRINT.callnumber)) {
hError -> getError(cat_bookinventoryTitle,"METS","DMDSEC MODSMD_PRINT", "wrong callNumber:" + context.inventory.inventoryMODSMD_PRINT.callnumber +" against :"+ invent.callnumber ,context.currentMetsFile,context.inventory.inventoryMODSMD_PRINT.callnumber);
}

if ( invent.BIBREC_100a.compare(context.inventory.inventoryMODSMD_PRINT.BIBREC_100a)) {
hError -> getError(cat_bookinventoryData,"METS","DMDSEC MODSMD_PRINT", "wrong BIBREC_100a:" + context.inventory.inventoryMODSMD_PRINT.BIBREC_100a +" against :"+ invent.BIBREC_100a ,context.currentMetsFile,context.inventory.inventoryMODSMD_PRINT.BIBREC_100a);

string partNumberBuild = buildPartNumber(invent.yearnumber,invent.issuenumber);
if ( partNumberBuild . compare(context.inventory.inventoryMODSMD_PRINT.partNumber)){
hError -> getError(cat_bookinventoryTitle,"METS","DMDSEC MODSMD_PRINT", "wrong partNumber:" + context.inventory.inventoryMODSMD_PRINT.partNumber +" against :"+ partNumberBuild ,context.currentMetsFile,context.inventory.inventoryMODSMD_PRINT.partNumber);
}
*/



// TODO compare must be base on any kind order of list

Expand All @@ -63,6 +68,33 @@ void verifyBook::check(int check,metsparserContext& context){

}

std::string verifyBook::buildPartNumber(std::string& yearNumber, std::string& issueNumber){

// Generation of : Jg. @yearNumber@, n° @issueNumber@
int yearLen = yearNumber.length();
int issueLen = issueNumber.length();

std::cout << "YEAR NUMBER:" << yearNumber << std::endl;
std::cout << "ISSUE NUMBER:" << issueNumber << std::endl;

std::stringstream ss;
if ( yearLen != 0 ){
ss << "Jg. " << yearNumber;
}

if ( issueLen != 0){
if ( yearLen != 0 ){ // ADD COMMA
ss << ", ";
}

ss << "" << issueNumber;
}

std::cout << "RESULTE" << ss.str() << std::endl;

return ss.str();
}

std::string verifyBook::buildTitle(inventory& invent){

std::string ret;
Expand Down
2 changes: 2 additions & 0 deletions project/verifybook.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ protected :

virtual void init(metsparserContext&);
std::string buildTitle(inventory&);
std::string buildPartNumber(std::string&,std::string&);

public :
verifyBook();
virtual void check(int,metsparserContext&);
Expand Down

0 comments on commit b2ce37e

Please sign in to comment.