public class DocumentMapperServiceImpl extends java.lang.Object implements DocumentMapperService
Modifier and Type | Class and Description |
---|---|
static class |
DocumentMapperServiceImpl.AnnoFSAttribute
holder for FeatureStruct attributes
|
static class |
DocumentMapperServiceImpl.AnnoLink |
static interface |
DocumentMapperServiceImpl.ChunkPreparedStatementSetter<T> |
Modifier and Type | Field and Description |
---|---|
private java.util.Set<AnnoMappingInfo> |
annoMappingInfos |
private int |
batchSize |
private javax.sql.DataSource |
dataSource |
private java.lang.String |
dbSchema |
private java.lang.String |
dbType |
private Dialect |
dialect |
private java.lang.String |
dialectClassName |
private CaseInsensitiveMap |
docTableCols |
private java.lang.String |
formattedTableName |
private JdbcTemplate |
jdbcTemplate |
private static Log |
log |
private java.util.Map<java.lang.String,AnnoMappingInfo> |
mapAnnoMappingInfo |
private static java.util.Set<java.lang.Integer> |
numericTypes |
private SessionFactory |
sessionFactory |
private static java.util.Set<java.lang.Integer> |
stringTypes |
private java.lang.ThreadLocal<java.util.Map<java.lang.String,AnnoMappingInfo>> |
tl_mapAnnoMappingInfo |
private java.lang.ThreadLocal< |
tl_mapFieldInfo
map of annotation to fields that need to be mapped
|
private static java.lang.ThreadLocal<java.text.DateFormat> |
tlAnalysisBatchDateFormat
date format for analysis batch.
|
private PlatformTransactionManager |
transactionManager |
private java.util.Map<java.lang.String,UimaType> |
uimaTypeMap |
private java.util.Properties |
ytexProperties |
Constructor and Description |
---|
DocumentMapperServiceImpl() |
Modifier and Type | Method and Description |
---|---|
private void |
addAnnoLinks(JCas jcas,
|
private void |
addAnnoLinks(JCas jcas,
|
private void |
addLink(
add a link.
|
void |
afterPropertiesSet()
load the map of uima annotation class name to mapper class name from the
database.
|
private <T> void |
chunkedBatchUpdate(java.lang.String sql,
java.util.List<T> l,
DocumentMapperServiceImpl.ChunkPreparedStatementSetter<T> cpss)
for the list l, perform l.size()/batchSize batch updates.
|
private Document |
createDocument(JCas jcas,
java.lang.String analysisBatch,
boolean bStoreDocText,
boolean bStoreCAS) |
private void |
extractAndSaveDocKey(JCas jcas,
Document doc) |
private java.lang.Object |
extractFeature(java.lang.String jxpath,
java.lang.Object child)
apply jxpath to object
|
private java.util.List<FeatureStructure> |
extractList(FeatureStructure fsc)
covert a FSArray or FSList into a List
|
java.util.Set<AnnoMappingInfo> |
getAnnoMappingInfos() |
int |
getBatchSize() |
javax.sql.DataSource |
getDataSource() |
java.lang.String |
getDbSchema() |
java.lang.String |
getDbType() |
private java.lang.String |
getDefaultAnalysisBatch() |
java.lang.String |
getDialectClassName() |
java.util.Map<java.lang.String,AnnoMappingInfo> |
getMapAnnoMappingInfo() |
private AnnoMappingInfo |
getMapInfo(FeatureStructure fs) |
SessionFactory |
getSessionFactory() |
private java.lang.String |
getTablePrefix() |
PlatformTransactionManager |
getTransactionManager() |
java.util.Properties |
getYtexProperties() |
void |
initDocKeyMapping() |
private AnnoMappingInfo |
initMapInfo(FeatureStructure fs)
load mapping info
|
private void |
insertAnnotationContainmentLinks(int documentId)
insert annotation containment links.
|
private |
saveAnnoBase(JCas jcas,
java.util.Set<java.lang.String> setTypesToIgnore,
int docId) |
private |
saveAnnoBaseHib(JCas jcas,
java.util.Set<java.lang.String> setTypesToIgnore,
Document doc) |
private void |
saveAnnoBindVariables(Type type,
AnnoMappingInfo mapInfo,
java.sql.PreparedStatement ps,
int annoId,
FeatureStructure anno,
bind the variables to the prepared statement
|
private void |
saveAnnoFS(java.util.List<DocumentMapperServiceImpl.AnnoFSAttribute> listFSA,
insert composite attributes.
|
private void |
saveAnnoLinks(java.util.List<DocumentMapperServiceImpl.AnnoLink> listAnnoLinks)
save annotation to annotation links (many-to-many relationships)
|
private void |
saveAnnoPrimitive(
save the annotation properties for a given type
|
private void |
saveAnnotationsHib(JCas jcas,
boolean bInsertAnnotationContainmentLinks,
java.util.Set<java.lang.String> setTypesToIgnore,
Document doc) |
private void |
saveDocKey(Document document,
DocKey dk)
update the document table - set key values from dockey for the give
document_id
|
java.lang.Integer |
saveDocument(JCas jcas,
java.lang.String analysisBatch,
boolean bStoreDocText,
boolean bStoreCAS,
boolean bInsertAnnotationContainmentLinks,
java.util.Set<java.lang.String> setTypesToIgnore)
Save Document and all mapped annotations.
|
void |
setAnnoMappingInfos(java.util.Set<AnnoMappingInfo> annoMappingInfos)
initialize mapAnnoMappingInfo from the set
|
void |
setBatchSize(int batchSize) |
void |
setDataSource(javax.sql.DataSource dataSource) |
void |
setDbSchema(java.lang.String dbSchema) |
void |
setDbType(java.lang.String dbType) |
void |
setDialectClassName(java.lang.String dialectClassName) |
void |
setMapAnnoMappingInfo(java.util.Map<java.lang.String,AnnoMappingInfo> mapAnnoMappingInfo) |
void |
setSessionFactory(SessionFactory sessionFactory) |
void |
setTransactionManager(PlatformTransactionManager transactionManager) |
private java.lang.String |
setUimaDocId(JCas jcas,
Document doc,
java.lang.String idType,
java.lang.String idFeature)
get the document id from the specified type and feature.
|
void |
setYtexProperties(java.util.Properties ytexProperties) |
private java.lang.String |
truncateString(java.lang.String val,
int size) |
private boolean |
updateSize(AnnoMappingInfo mapInfo,
java.lang.String colName,
int colSize,
int sqlType)
update column size for given column, if the column has been mapped
|
private static final Log log
private static java.util.Set<java.lang.Integer> numericTypes
private static java.util.Set<java.lang.Integer> stringTypes
private static final java.lang.ThreadLocal<java.text.DateFormat> tlAnalysisBatchDateFormat
private java.util.Set<AnnoMappingInfo> annoMappingInfos
private int batchSize
private javax.sql.DataSource dataSource
private java.lang.String dbSchema
private java.lang.String dbType
private Dialect dialect
private java.lang.String dialectClassName
private CaseInsensitiveMap docTableCols
private java.lang.String formattedTableName
private JdbcTemplate jdbcTemplate
private java.util.Map<java.lang.String,AnnoMappingInfo> mapAnnoMappingInfo
private SessionFactory sessionFactory
private java.lang.ThreadLocal<java.util.Map<java.lang.String,AnnoMappingInfo>> tl_mapAnnoMappingInfo
private java.lang.ThreadLocal<> tl_mapFieldInfo
private PlatformTransactionManager transactionManager
private java.util.Map<java.lang.String,UimaType> uimaTypeMap
private java.util.Properties ytexProperties
private void addAnnoLinks(JCas jcas,mapAnnoToId, java.util.List<DocumentMapperServiceImpl.AnnoLink> listAnnoLinks)
private void addAnnoLinks(JCas jcas,mapAnnoToId, java.util.List<DocumentMapperServiceImpl.AnnoLink> listAnnoLinks, AnnoMappingInfo mi)
private void addLink(mapAnnoToId, java.util.List<DocumentMapperServiceImpl.AnnoLink> listAnnoLinks, java.lang.String linkType, java.lang.String childJxpath, java.lang.Integer parentId, FeatureStructure child)
mapAnnoToId
- map to find existing annoslistAnnoLinks
- list to populatelinkType
- anno_link.featurechildJxpath
- jxpath to child annotation feature value, can be nullparentId
- parent_anno_base_idchild
- child object to apply jxpath to, or which is already an
annotationpublic void afterPropertiesSet()
java.lang.Exception
private Document createDocument(JCas jcas, java.lang.String analysisBatch, boolean bStoreDocText, boolean bStoreCAS)
private void extractAndSaveDocKey(JCas jcas, Document doc)
private java.lang.Object extractFeature(java.lang.String jxpath, java.lang.Object child)
jxpath
- child
- private java.util.List<FeatureStructure> extractList(FeatureStructure fsc)
fsc
- public java.util.Set<AnnoMappingInfo> getAnnoMappingInfos()
public int getBatchSize()
public javax.sql.DataSource getDataSource()
public java.lang.String getDbSchema()
public java.lang.String getDbType()
private java.lang.String getDefaultAnalysisBatch()
public java.lang.String getDialectClassName()
public java.util.Map<java.lang.String,AnnoMappingInfo> getMapAnnoMappingInfo()
private AnnoMappingInfo getMapInfo(FeatureStructure fs)
public SessionFactory getSessionFactory()
private java.lang.String getTablePrefix()
public PlatformTransactionManager getTransactionManager()
public java.util.Properties getYtexProperties()
public void initDocKeyMapping()
private AnnoMappingInfo initMapInfo(FeatureStructure fs)
type
- private void insertAnnotationContainmentLinks(int documentId)
documentId
- privatesaveAnnoBase(JCas jcas, java.util.Set<java.lang.String> setTypesToIgnore, int docId)
privatesaveAnnoBaseHib(JCas jcas, java.util.Set<java.lang.String> setTypesToIgnore, Document doc)
private void saveAnnoBindVariables(Type type, AnnoMappingInfo mapInfo, java.sql.PreparedStatement ps, int annoId, FeatureStructure anno,mapAnnoToId) throws java.sql.SQLException
type
- mapInfo
- ps
- annoId
- anno
- java.sql.SQLException
private void saveAnnoFS(java.util.List<DocumentMapperServiceImpl.AnnoFSAttribute> listFSA,mapAnnoToId)
listFSA
- private <T> void chunkedBatchUpdate(java.lang.String sql, java.util.List<T> l, DocumentMapperServiceImpl.ChunkPreparedStatementSetter<T> cpss)
sql
- l
- cpss
- private void saveAnnoLinks(java.util.List<DocumentMapperServiceImpl.AnnoLink> listAnnoLinks)
listAnnoLinks
- private void saveAnnoPrimitive(mapAnnoToId, java.util.Set<java.lang.Integer> annoIds, java.util.List<DocumentMapperServiceImpl.AnnoLink> listAnnoLinks)
mapIdToAnno
- map of all annoIDs to AnnotationannoIds
- annotation ids for a single typelistAnnoLinks
- annotation to annotation links to saveprivate void saveAnnotationsHib(JCas jcas, boolean bInsertAnnotationContainmentLinks, java.util.Set<java.lang.String> setTypesToIgnore, Document doc)
private void saveDocKey(Document document, DocKey dk)
document
- documentdk
- keypublic java.lang.Integer saveDocument(JCas jcas, java.lang.String analysisBatch, boolean bStoreDocText, boolean bStoreCAS, boolean bInsertAnnotationContainmentLinks, java.util.Set<java.lang.String> setTypesToIgnore)
DocumentMapperService
saveDocument
in interface DocumentMapperService
analysisBatch
- optionalpublic void setAnnoMappingInfos(java.util.Set<AnnoMappingInfo> annoMappingInfos)
annoMappingInfos
- public void setBatchSize(int batchSize)
public void setDataSource(javax.sql.DataSource dataSource)
public void setDbSchema(java.lang.String dbSchema)
public void setDbType(java.lang.String dbType)
public void setDialectClassName(java.lang.String dialectClassName)
public void setMapAnnoMappingInfo(java.util.Map<java.lang.String,AnnoMappingInfo> mapAnnoMappingInfo)
public void setSessionFactory(SessionFactory sessionFactory)
public void setTransactionManager(PlatformTransactionManager transactionManager)
private java.lang.String setUimaDocId(JCas jcas, Document doc, java.lang.String idType, java.lang.String idFeature)
jcas
- doc
- idType
- idFeature
- public void setYtexProperties(java.util.Properties ytexProperties)
private java.lang.String truncateString(java.lang.String val, int size)
private boolean updateSize(AnnoMappingInfo mapInfo, java.lang.String colName, int colSize, int sqlType)
mapInfo
- colName
- colSize
-