Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
rhbz980658 add contentLocation to HRawDocument in preparation for con…
Browse files Browse the repository at this point in the history
…tent migration
  • Loading branch information
davidmason committed Jul 23, 2013
1 parent f3c20c9 commit 076b807
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
Expand Up @@ -52,6 +52,7 @@ public class HRawDocument extends ModelEntityBase implements Serializable

// TODO none of these should allow null
private String contentHash;
private String contentLocation;
private Blob content;
private DocumentType type;
private String uploadedBy;
Expand Down Expand Up @@ -105,6 +106,9 @@ public String toString()
+ ",contentHash=" + contentHash + "]";
}

// TODO override equals to use contentHash
// TODON'T: override equals to use contentHash would be logically flawed
// same document with different parameters leads to different text flows
// different types could theoretically share the same hash, but would be parsed
// completely differently.

}
Expand Up @@ -82,6 +82,11 @@ public void persistRawDocumentContentFromFile(HRawDocument rawDocument, File raw
LobHelper lobHelper = documentDAO.getLobHelper();
Blob fileContents = lobHelper.createBlob(tempFileStream, (int) rawFile.length());
rawDocument.setContent(fileContents);

// FIXME temporary id assignment during blob migration - needs to be unique but only while
// migration is in progress.
String temporaryLocation = "document:" + rawDocument.getDocument().getId().toString();
rawDocument.setContentLocation(temporaryLocation);
}

@Override
Expand Down
14 changes: 14 additions & 0 deletions zanata-war/src/main/resources/db/changelogs/db.changelog-3.1.xml
Expand Up @@ -67,6 +67,20 @@
</sql>
</changeSet>

<changeSet author="damason@redhat.com" id="1">
<comment>Add contentLocation to HRawDocument</comment>
<addColumn tableName="HRawDocument">
<column name="contentLocation" type="longtext" />
</addColumn>
</changeSet>

<changeSet author="damason@redhat.com" id="2">
<comment>Initialise contentLocation with id, can guarantee uniqueness during migration</comment>
<sql>
update HRawDocument set contentLocation = id
</sql>
<addNotNullConstraint tableName="HRawDocument" columnName="contentLocation" columnDataType="longtext" />
</changeSet>


</databaseChangeLog>

0 comments on commit 076b807

Please sign in to comment.