Skip to content

Commit

Permalink
Refactor AmdSec struct name to AmdSecMix
Browse files Browse the repository at this point in the history
  • Loading branch information
Ra1phM committed Nov 12, 2018
1 parent eb6f97b commit f043031
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions common_files/struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ struct File_Group : public dataitem
};

//! structure of an amdsec
struct AmdSec : public dataitem
struct AmdSecMix : public dataitem
{
static const size_t DATAITEM_ID =7;
std::string amdSecId;
std::string sourceData; // mix:ChangeHistory/mix:ImageProcessing/mix:SourceData for cut-outs
int dpi;
};

// TODO: Refactor AmdSec to AmdSecMix and add AmdSecOdrl. Break the code and compile.
// TODO: [Refactor AmdSec to AmdSecMix] (OK) and add AmdSecOdrl. Break the code and compile.

//! structure of a block type
struct typeBlock
Expand Down
2 changes: 1 addition & 1 deletion project/Project.vcproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
Version="9.00"
Name="metsverifier"
ProjectGUID="{812C7CD2-25D6-4B22-ACE5-2096E654ED0C}"
RootNamespace="Project"
Expand Down
16 changes: 8 additions & 8 deletions project/metsparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class StateParserScanResolution : public StateParserRootamdSecState{
std::string cData;
public:
virtual void startElement (const char* const name, const xercesc::Attributes &atts ){
//cerr << "StateParserScanResolution:" << name << " AMID:" << CTX.amdsec.amdSecId << endl;
//cerr << "StateParserScanResolution:" << name << " AMID:" << CTX.amdSecMix.amdSecId << endl;
cData.clear();
};

Expand All @@ -74,8 +74,8 @@ class StateParserScanResolution : public StateParserRootamdSecState{

virtual void endElement (const char* const name){
boost::algorithm::trim(cData);
CTX.amdsec.dpi = atoi(cData.c_str());
//printf("DPI FOUND: %d\n", CTX.amdsec.dpi);
CTX.amdSecMix.dpi = atoi(cData.c_str());
//printf("DPI FOUND: %d\n", CTX.amdSecMix.dpi);
};

};
Expand All @@ -84,7 +84,7 @@ class StateParserSourceDataResolution : public StateParserScanResolution{
public:
virtual void endElement (const char* const name){
boost::algorithm::trim(cData);
CTX.amdsec.sourceData = cData;
CTX.amdSecMix.sourceData = cData;
};
};

Expand All @@ -105,7 +105,7 @@ void StateParseramdSecState::startElement (const char* const name, const xercesc
/* THIS IS MOVED TO the RootGeneralAmdSecState.startElement method
const char *val = getAttributeValue("ID", atts);
if (val!=0) {
CTX.amdsec.amdSecId = val;
CTX.amdSecMix.amdSecId = val;
}*/

if ( CTX.flagMix ) {
Expand All @@ -132,7 +132,7 @@ void StateParseramdSecState::startElement (const char* const name, const xercesc
Improvement: MixContainerNotDefine should be a set. The value for key is not used.
*/
void StateParseramdSecState::endElement (const char* const name){
//CTX.dfMets->set(CTX.amdsec.amdSecId,CTX.amdsec); // TODO: Should this be moved to RootGeneralAmdSecState.endElement ??
//CTX.dfMets->set(CTX.amdSecMix.amdSecId,CTX.amdSecMix); // TODO: Should this be moved to RootGeneralAmdSecState.endElement ??

if ( CTX.flagMix ) {
if ( CTX.mandatoryField.size() != 0 ) {
Expand Down Expand Up @@ -249,14 +249,14 @@ class StateParserGeneralAmdSecState : public StateParserRootGeneralAmdSecState {
virtual void startElement (const char* const name, const xercesc::Attributes &atts ) {
const char *attribute_id = getAttributeValue("ID", atts);
if (attribute_id != 0) {
CTX.amdsec.amdSecId = attribute_id;
CTX.amdSecMix.amdSecId = attribute_id;
}

//std::cout << "StateParserGeneralAmdSecState: START ELEMENT : " << attribute_id << std::endl;
};

virtual void endElement (const char* const name) {
CTX.dfMets->set(CTX.amdsec.amdSecId,CTX.amdsec);
CTX.dfMets->set(CTX.amdSecMix.amdSecId,CTX.amdSecMix);

//std::cout << "StateParserGeneralAmdSecState: END ELEMENT" << std::endl;

Expand Down
6 changes: 3 additions & 3 deletions project/metsparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ public :
Type_File f;
File_Group file_group;

// dmd
// dmdSec
std::string idItem;
std::string addStringData;
dmdsec dmdSecStruct;

// amdsec
AmdSec amdsec;
// amdSec
AmdSecMix amdSecMix;

// TODO: Use kind of Enum
// Possible values: MIX, ODRL
Expand Down
4 changes: 2 additions & 2 deletions project/sql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ void database::insertLinkedFiles(int id_mets,datafactory *df)
sqlite3_stmt *pStmt = 0;

datafactory_set<File_Group> dftypefile = df->get_set<File_Group>();
datafactory_set<AmdSec> dfamdsec = df->get_set<AmdSec>();
datafactory_set<AmdSecMix> dfamdsec = df->get_set<AmdSecMix>();

const char *sql = "INSERT INTO LINKEDFILES ('ID_METS', 'TYPE', 'GROUPID', 'CHECKSUM','SIZE','FILENAME','FILEID','DPI') VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
if (sqlite3_prepare_v2(db, sql, -1, &pStmt, &zErrMsg) == SQLITE_OK) {
Expand All @@ -404,7 +404,7 @@ void database::insertLinkedFiles(int id_mets,datafactory *df)
int dpi =0;
if (it.key() == "IMGGRP")
{
AmdSec *s = df->get<AmdSec>(tf.admid); // get the dpi of image
AmdSecMix *s = df->get<AmdSecMix>(tf.admid); // get the dpi of image
if ( s!= NULL) {
dpi = s->dpi;
}else{
Expand Down
4 changes: 2 additions & 2 deletions project/verifycutouts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ void verifycutouts(datafactory *df, errorHandler *h, std::string &fileName)
{
bool foundOne = false;
h->begin("Verify: cut-out references in mix");
datafactory_set<AmdSec> dfAmdSec = df->get_set<AmdSec>();
datafactory_set<AmdSecMix> dfAmdSec = df->get_set<AmdSecMix>();
datafactory_set<File_Group> dfFileGrp = df->get_set<File_Group>();
for (datafactory_set<AmdSec>::iterator it = dfAmdSec.begin(); it != dfAmdSec.end(); ++it) {
for (datafactory_set<AmdSecMix>::iterator it = dfAmdSec.begin(); it != dfAmdSec.end(); ++it) {
if (it->sourceData.length()) {
// Look for the identifier in the fileGrp
foundOne = false;
Expand Down
6 changes: 3 additions & 3 deletions project/verifyidentifierinmix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ verifyidentifierinmix::verifyidentifierinmix(datafactory *dfverifiers,errorHandl
fg = dfverifiers->get<File_Group>("IMGGRP");
for(size_t j=0;j< fg->vect.size();j++)
{
AmdSec *amdsec = dfverifiers->get<AmdSec>(fg->vect[j].admid);
if (amdsec ==0)
AmdSecMix *amdSecMix = dfverifiers->get<AmdSecMix>(fg->vect[j].admid);
if (amdSecMix ==0)
{
hError->getError(cat_amdsecID,"METS","MIX",fg->vect[j].admid,fileName,"<amdsec");
hError->getError(cat_amdsecID,"METS","MIX",fg->vect[j].admid,fileName,"<amdSecMix");
}
}
}

0 comments on commit f043031

Please sign in to comment.