Skip to content

Commit

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

More ltopers db integration
  • Loading branch information
privatezero authored Feb 7, 2017
2 parents 5413c66 + 46abf33 commit 2aaf09d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions createpremisdb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ echo "CREATE TABLE object (objectIdentifierValueID bigint NOT NULL AUTO_INCREMEN
echo "CREATE TABLE event (eventIdentifierValue bigint NOT NULL AUTO_INCREMENT,objectIdentifierValue varchar(1000) NOT NULL,eventType varchar(100) NOT NULL,eventDateTime datetime NOT NULL DEFAULT NOW(),eventDetail varchar(30) NOT NULL,eventOutcome varchar(30),eventDetailOPT varchar(1000),eventDetailCOMPNAME varchar(50) NOT NULL,linkingAgentIdentifierValue varchar(30) NOT NULL,PRIMARY KEY (eventIdentifierValue),FOREIGN KEY (objectIdentifierValue) REFERENCES object(objectIdentifierValue))" | mysql --login-path=tempsetting "$DB_NAME"
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"
_error_check
#remove root config
mysql_config_editor remove --login-path=tempsetting
Expand Down
26 changes: 25 additions & 1 deletion mmfunctions
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ _report_to_db(){
INGESTLOG="${LOGDIR}/capture.log"
if [ -f "${INGESTLOG}" ] ; then
OP=$(grep "operator" "${INGESTLOG}" | cut -c 11-)
else
OP="${OP}"
fi
if [ -z "${OP}" ] ; then
OP="${USER}"
Expand All @@ -48,6 +50,24 @@ _report_to_db(){
fi
}

_report_schema_db(){
if [ "${PREMIS_DB}" = "Y" ] ; then
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}")
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
done)
unset IFS
_db_error_check
fi
}

_report_fixity_db(){
if [ "${PREMIS_DB}" = "Y" ] ; then
_premis_event_list
Expand Down Expand Up @@ -103,7 +123,7 @@ _db_error_check(){
LINE=$i;
messageDigestHASH=$(echo "$LINE" | cut -c -32 )
messageDigestPATH=$(echo "$LINE" | cut -c 35- )
messageDigestFILENAME=$(basename ${messageDigestPATH})
messageDigestFILENAME=$(basename "${messageDigestPATH}")
echo "echo \"INSERT INTO fixity (eventIdentifierValue,objectIdentifierValue,eventDetail,messageDigestAlgorithm,messageDigestPATH,messageDigestFILENAME,messageDigestHASH) VALUES ('${EVENT_ID_TRIM}','${MEDIAID}','md5','${messageDigestPATH}','${messageDigestFILENAME}','${messageDigestHASH}')\" | mysql --login-path=\"${PREMIS_PROFILE}\" \"${PREMIS_NAME}\"" >> ~/Desktop/"${MEDIA_ID}"_dbreport.txt
done
unset IFS
Expand All @@ -118,6 +138,10 @@ _db_error_check(){
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

}

_premis_event_list(){
Expand Down

0 comments on commit 2aaf09d

Please sign in to comment.