Skip to content

Commit

Permalink
Title TitleCollection 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 8, 2018
1 parent b053300 commit 1a74698
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 5 deletions.
57 changes: 56 additions & 1 deletion project/metsparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,28 @@ private :

};

class StateTitleState : public StateParserMetsRootState{
private :
std::string value;
public:

StateTitleState(std::string _value):value(_value){};

virtual void characters (const char* const s, const int len){
CTX.addStringData += xml2str(s,len);
}

virtual void endElement (const char* const name){
CTX.addStringData += value;
};


};

class StateDoNothingState : public StateParserMetsRootState{
public:
};

class StateParsermodStateInventory:public StateParsermodState{
private:
std::string value;
Expand All @@ -220,6 +242,39 @@ class StateParsermodStateInventory:public StateParsermodState{
};
};

class StateParsermodStateTitleInfoInventory:public StateParsermodState{

public:
StateParsermodStateTitleInfoInventory(){};

StateParserState* getNext(const char* const name){
static std::map<string,StateParserMetsRootState*> map;
static StateParserState* root=this;

StateParserState* ret=root;

static struct _onlyOnes {
_onlyOnes(std::map<string,StateParserMetsRootState*>& map){
//static int i = 0;
//std::cerr << "Only Ones :"<< ++i << std::endl;
map["title"]= new StateParsermodStateInventory("title");
map["nonSort"]= new StateTitleState(" ");
map["partNumber"]= new StateDoNothingState();
}
} onlyOnes (map);

if (CTX.inventory.isActif()){
std::map<string,StateParserMetsRootState*>::iterator it = map.find(name);
if ( it != map.end()) ret = (*it).second;
};

return ret;


};

};

class StateParsermodStateInventoryMarc:public StateParsermodState{
private:
std::string value;
Expand All @@ -244,7 +299,7 @@ StateParserState* StateParsermodState::getNext(const char* const name){
//static int i = 0;
//std::cerr << "Only Ones :"<< ++i << std::endl;
map["recordIdentifier"]= new StateParsermodStateInventory("recordIdentifier");
map["title"]= new StateParsermodStateInventory("title");
map["titleInfo"]= new StateParsermodStateTitleInfoInventory();
map["identifier"]= new StateParsermodStateInventory("identifier");
map["languageTerm"]=new StateParsermodStateInventory("languageTerm");
map["dateIssued"]= new StateParsermodStateInventory("dateIssued");
Expand Down
3 changes: 2 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,PAGES"
" LANGUAGES,FORMALDATE,TYPE,TITLE,TITLECOLLECTION,PAGES"
" CHECKED"
" from INVENTORY where UNIQUEBUILDKEY=?";

Expand Down Expand Up @@ -220,6 +220,7 @@ bool database::getInventory(std::string _sysnum, inventory& _inventory){
_inventory.formaldate = safe_sqlite3_column_text(pStmt, col++);
_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.pages = safe_sqlite3_column_text(pStmt, col++);

_inventory.checked = sqlite3_column_int(pStmt, col++);
Expand Down
6 changes: 3 additions & 3 deletions project/verifyBook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ void verifyBook::check(int check,metsparserContext& context){
hError -> getError(cat_bookinventoryTitle,"METS","DMDSEC MODSMD_PRINT", "wrong title:" + context.inventory.inventoryMODSMD_PRINT.title +" against :"+ invent.title ,context.currentMetsFile,context.inventory.inventoryMODSMD_PRINT.title);
}

title = buildTitle( context.inventory.inventoryMODSMD_COLLECTION);
if ( invent.title.compare(title)) {
hError -> getError(cat_bookinventoryTitle,"METS","DMDSEC MODSMD_COLLECTION", "wrong title:" + context.inventory.inventoryMODSMD_COLLECTION.title +" against :"+ invent.title ,context.currentMetsFile,context.inventory.inventoryMODSMD_COLLECTION.title);
title = buildTitle( context.inventory.inventoryMODSMD_COLLECTION); // in the xml in title
if ( invent.titlecollection.compare(title)) {
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
Expand Down

0 comments on commit 1a74698

Please sign in to comment.