Skip to content

Commit

Permalink
Merge pull request #128 from mediamicroservices/more-ltopers-db-integ…
Browse files Browse the repository at this point in the history
…ration

prevents duplicate records for schemas
  • Loading branch information
privatezero authored Feb 7, 2017
2 parents 2aaf09d + 637ec35 commit ffff7da
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
1 change: 1 addition & 0 deletions createpremisdb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ echo "CREATE TABLE event (eventIdentifierValue bigint NOT NULL AUTO_INCREMENT,ob
echo "CREATE TABLE fixity (fixityIdentifierValue bigint NOT NULL AUTO_INCREMENT,eventIdentifierValue bigint NOT NULL, objectIdentifierValue varchar(1000),eventDateTime datetime NOT NULL DEFAULT NOW(),eventDetail varchar(30) NOT NULL,messageDigestAlgorithm varchar (20) NOT NULL,messageDigestPATH varchar (8000) NOT NULL,messageDigestFILENAME varchar (8000) NOT NULL,messageDigestHASH varchar (32) NOT NULL,PRIMARY KEY (fixityIdentifierValue),FOREIGN KEY (eventIdentifierValue) REFERENCES event(eventIdentifierValue), FOREIGN KEY (objectIdentifierValue) REFERENCES object(objectIdentifierValue))" | mysql --login-path=tempsetting "$DB_NAME"
echo "CREATE TABLE objectCharacteristics (objectCharacteristicValueID bigint NOT NULL AUTO_INCREMENT, objectIdentifierValue varchar(1000) NOT NULL,mediaInfo MEDIUMTEXT, PRIMARY KEY (objectCharacteristicValueID),FOREIGN KEY (objectIdentifierValue) REFERENCES object(objectIdentifierValue))" | mysql --login-path=tempsetting "$DB_NAME"
echo "CREATE TABLE ltoSchema (ltoSchemaValueID bigint NOT NULL AUTO_INCREMENT, ltoID varchar(10) NOT NULL,fileName varchar(200),fileSize varchar(100),fileDate varchar(40),PRIMARY KEY (ltoSchemaValueID))" | mysql --login-path=tempsetting "$DB_NAME"
echo "CREATE UNIQUE INDEX lto_column_index ON ltoSchema(ltoID,fileName,fileSize,fileDate)" | mysql --login-path=tempsetting "$DB_NAME"
_error_check
#remove root config
mysql_config_editor remove --login-path=tempsetting
Expand Down
13 changes: 6 additions & 7 deletions mmfunctions
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ _report_schema_db(){
table_name="ltoSchema"
xmlschema="$LTO_LOGS/${TAPE_SERIAL}.schema"
schema_sorted=$(xml sel -t -m "/ltfsindex/directory/contents/directory/contents/file" -v "concat(name,'|',length, '|', modifytime)" -n "${xmlschema}")
schema_tape=$(basename "${xmlschema}" | cut -d'.' -f1)
IFS=$(echo -en "\n\b")
(for i in ${schema_sorted}; do LINE=$i;
schema_tape=$(basename "${xmlschema}" | cut -d'.' -f1)
schema_name=$(echo "${LINE}" | cut -d'|' -f1)
schema_length=$(echo "${LINE}" | cut -d'|' -f2)
schema_date=$(echo "${LINE}" | cut -d'|' -f3)
echo "INSERT INTO ltoSchema (ltoID,fileName,fileSize,fileDate) VALUES ('${schema_tape}','${schema_name}','${schema_length}','$schema_date')" | mysql --login-path="${PREMIS_PROFILE}" "${PREMIS_NAME}" 2> /dev/null
echo "INSERT IGNORE INTO ltoSchema (ltoID,fileName,fileSize,fileDate) VALUES ('${schema_tape}','${schema_name}','${schema_length}','$schema_date')" | mysql --login-path="${PREMIS_PROFILE}" "${PREMIS_NAME}" 2> /dev/null
done)
unset IFS
_db_error_check
Expand Down Expand Up @@ -135,13 +135,12 @@ _db_error_check(){
if [ "${table_name}" = "objectCharacteristics" ] ; then
echo "echo \"INSERT IGNORE INTO objectCharacteristics (objectIdentifierValue,mediaInfo) VALUES ('${MEDIA_ID}','${MEDIAINFO}')\" | mysql --login-path=\"${PREMIS_PROFILE}\" \"$PREMIS_NAME\"" >> ~/Desktop/"$MEDIA_ID"_dbreport.txt
fi
if [ "${table_name}" = "ltoSchema" ] ; then
echo "echo \"INSERT INTO ltoSchema (ltoID,fileName,fileSize,fileDate) VALUES ('${schema_tape}','${schema_name}','${schema_length}','$schema_date')\" | mysql --login-path=\"${PREMIS_PROFILE}\" \"${PREMIS_NAME}\"" >> ~/Desktop/"$MEDIA_ID"_dbreport.txt
fi
else
echo -e "\033[1;103;95mSuccessfully reported infomation to the "${table_name}" table in the database "${PREMIS_NAME}"\033[0m"
fi
if [ "${table_name}" = "ltoSchema" ] ; then
echo "echo \"INSERT INTO ltoSchema (ltoID,fileName,fileSize,fileDate) VALUES ('${schema_tape}','${schema_name}','${schema_length}','$schema_date')\" | mysql --login-path=\"${PREMIS_PROFILE}\" \"${PREMIS_NAME}\"" >> ~/Desktop/"$MEDIA_ID"_dbreport.txt
fi

fi
}

_premis_event_list(){
Expand Down

0 comments on commit ffff7da

Please sign in to comment.