use of eu.etaxonomy.cdm.model.name.NomenclaturalSource in project cdmlib by cybertaxonomy.
the class CommonServiceImpl method getReferencingObjectTarget.
private UuidAndTitleCache<CdmBase> getReferencingObjectTarget(CdmBase entity) {
CdmBase targetEntity;
entity = CdmBase.deproxy(entity);
if (entity instanceof SecundumSource) {
targetEntity = ((SecundumSource) entity).getSourcedTaxon();
} else if (entity instanceof NomenclaturalSource) {
targetEntity = ((NomenclaturalSource) entity).getSourcedName();
} else if (entity instanceof DescriptionElementSource) {
DescriptionElementBase element = ((DescriptionElementSource) entity).getSourcedElement();
targetEntity = getTarget(element);
} else if (entity instanceof DescriptionElementBase) {
targetEntity = getTarget((DescriptionElementBase) entity);
} else if (entity instanceof IdentifiableSource) {
IdentifiableSource source = (IdentifiableSource) entity;
targetEntity = originalSourceDao.findIdentifiableBySourceId(IdentifiableEntity.class, source.getId());
} else if (entity instanceof NamedSource) {
NamedSource source = (NamedSource) entity;
SingleSourcedEntityBase singleSourced = originalSourceDao.findSingleSourceBySourceId(SingleSourcedEntityBase.class, source.getId());
if (singleSourced != null) {
targetEntity = singleSourced;
} else {
// TODO
targetEntity = entity;
}
} else if (entity instanceof DescriptionBase) {
targetEntity = getTarget((DescriptionBase<?>) entity);
} else {
targetEntity = entity;
}
targetEntity = CdmBase.deproxy(targetEntity);
if (targetEntity == null) {
targetEntity = entity;
}
String targetLabel = targetEntity instanceof IdentifiableEntity ? ((IdentifiableEntity<?>) targetEntity).getTitleCache() : null;
UuidAndTitleCache<CdmBase> result = new UuidAndTitleCache<>(targetEntity.getClass(), targetEntity.getUuid(), targetEntity.getId(), targetLabel);
return result;
}
use of eu.etaxonomy.cdm.model.name.NomenclaturalSource in project cdmlib by cybertaxonomy.
the class CdmLightClassificationExport method handleName.
private void handleName(CdmLightExportState state, TaxonName name, Taxon acceptedTaxon, boolean acceptedName) {
if (name == null || state.getNameStore().containsKey(name.getId())) {
return;
}
try {
Rank rank = name.getRank();
CdmLightExportTable table = CdmLightExportTable.SCIENTIFIC_NAME;
name = HibernateProxyHelper.deproxy(name);
state.getNameStore().put(name.getId(), name.getUuid());
String[] csvLine = new String[table.getSize()];
csvLine[table.getIndex(CdmLightExportTable.NAME_ID)] = getId(state, name);
if (name.getLsid() != null) {
csvLine[table.getIndex(CdmLightExportTable.LSID)] = name.getLsid().getLsid();
} else {
csvLine[table.getIndex(CdmLightExportTable.LSID)] = "";
}
handleIdentifier(state, name);
handleDescriptions(state, name);
csvLine[table.getIndex(CdmLightExportTable.RANK)] = getTitleCache(rank);
if (rank != null) {
csvLine[table.getIndex(CdmLightExportTable.RANK_SEQUENCE)] = String.valueOf(rank.getOrderIndex());
if (rank.isInfraGeneric()) {
try {
csvLine[table.getIndex(CdmLightExportTable.INFRAGENERIC_RANK)] = name.getRank().getInfraGenericMarker();
} catch (UnknownCdmTypeException e) {
state.getResult().addError("Infrageneric marker expected but not available for rank " + name.getRank().getTitleCache());
}
}
if (rank.isInfraSpecific()) {
csvLine[table.getIndex(CdmLightExportTable.INFRASPECIFIC_RANK)] = name.getRank().getAbbreviation();
}
} else {
csvLine[table.getIndex(CdmLightExportTable.RANK_SEQUENCE)] = "";
}
if (name.isProtectedTitleCache()) {
csvLine[table.getIndex(CdmLightExportTable.FULL_NAME_WITH_AUTHORS)] = name.getTitleCache();
} else {
// TODO: adapt the tropicos titlecache creation
csvLine[table.getIndex(CdmLightExportTable.FULL_NAME_WITH_AUTHORS)] = name.getTitleCache();
}
if (!state.getConfig().isAddHTML()) {
csvLine[table.getIndex(CdmLightExportTable.FULL_NAME_WITH_REF)] = name.getFullTitleCache();
} else {
List<TaggedText> taggedFullTitleCache = name.getTaggedFullTitle();
List<TaggedText> taggedName = name.getTaggedName();
String fullTitleWithHtml = createNameWithItalics(taggedFullTitleCache);
// TODO: adapt the tropicos titlecache creation
csvLine[table.getIndex(CdmLightExportTable.FULL_NAME_WITH_REF)] = fullTitleWithHtml.trim();
}
csvLine[table.getIndex(CdmLightExportTable.FULL_NAME_NO_AUTHORS)] = name.getNameCache();
csvLine[table.getIndex(CdmLightExportTable.GENUS_UNINOMIAL)] = name.getGenusOrUninomial();
csvLine[table.getIndex(CdmLightExportTable.INFRAGENERIC_EPITHET)] = name.getInfraGenericEpithet();
csvLine[table.getIndex(CdmLightExportTable.SPECIFIC_EPITHET)] = name.getSpecificEpithet();
csvLine[table.getIndex(CdmLightExportTable.INFRASPECIFIC_EPITHET)] = name.getInfraSpecificEpithet();
csvLine[table.getIndex(CdmLightExportTable.APPENDED_PHRASE)] = name.getAppendedPhrase();
csvLine[table.getIndex(CdmLightExportTable.BAS_AUTHORTEAM_FK)] = getId(state, name.getBasionymAuthorship());
if (name.getBasionymAuthorship() != null) {
if (state.getAuthorFromStore(name.getBasionymAuthorship().getId()) == null) {
handleAuthor(state, name.getBasionymAuthorship());
}
}
csvLine[table.getIndex(CdmLightExportTable.BAS_EX_AUTHORTEAM_FK)] = getId(state, name.getExBasionymAuthorship());
if (name.getExBasionymAuthorship() != null) {
if (state.getAuthorFromStore(name.getExBasionymAuthorship().getId()) == null) {
handleAuthor(state, name.getExBasionymAuthorship());
}
}
csvLine[table.getIndex(CdmLightExportTable.COMB_AUTHORTEAM_FK)] = getId(state, name.getCombinationAuthorship());
if (name.getCombinationAuthorship() != null) {
if (state.getAuthorFromStore(name.getCombinationAuthorship().getId()) == null) {
handleAuthor(state, name.getCombinationAuthorship());
}
}
csvLine[table.getIndex(CdmLightExportTable.COMB_EX_AUTHORTEAM_FK)] = getId(state, name.getExCombinationAuthorship());
if (name.getExCombinationAuthorship() != null) {
if (state.getAuthorFromStore(name.getExCombinationAuthorship().getId()) == null) {
handleAuthor(state, name.getExCombinationAuthorship());
}
}
csvLine[table.getIndex(CdmLightExportTable.AUTHOR_TEAM_STRING)] = name.getAuthorshipCache();
Reference nomRef = name.getNomenclaturalReference();
NomenclaturalSource nomenclaturalSource = name.getNomenclaturalSource();
if (nomenclaturalSource != null && nomenclaturalSource.getNameUsedInSource() != null) {
handleName(state, nomenclaturalSource.getNameUsedInSource(), null);
csvLine[table.getIndex(CdmLightExportTable.NAME_USED_IN_SOURCE)] = getId(state, nomenclaturalSource.getNameUsedInSource());
}
if (nomRef != null) {
if (!state.getReferenceStore().contains(nomRef.getUuid())) {
handleReference(state, nomRef);
}
csvLine[table.getIndex(CdmLightExportTable.REFERENCE_FK)] = getId(state, nomRef);
csvLine[table.getIndex(CdmLightExportTable.PUBLICATION_TYPE)] = nomRef.getType().name();
if (nomRef.getVolume() != null) {
csvLine[table.getIndex(CdmLightExportTable.VOLUME_ISSUE)] = nomRef.getVolume();
csvLine[table.getIndex(CdmLightExportTable.COLLATION)] = createCollatation(name);
}
if (nomRef.getDatePublished() != null) {
csvLine[table.getIndex(CdmLightExportTable.DATE_PUBLISHED)] = nomRef.getTimePeriodPublishedString();
csvLine[table.getIndex(CdmLightExportTable.YEAR_PUBLISHED)] = nomRef.getDatePublished().getYear();
csvLine[table.getIndex(CdmLightExportTable.VERBATIM_DATE)] = nomRef.getDatePublished().getVerbatimDate();
}
if (name.getNomenclaturalMicroReference() != null) {
csvLine[table.getIndex(CdmLightExportTable.DETAIL)] = name.getNomenclaturalMicroReference();
}
nomRef = HibernateProxyHelper.deproxy(nomRef);
if (nomRef.getInReference() != null) {
Reference inReference = nomRef.getInReference();
if (inReference.getDatePublished() != null && nomRef.getDatePublished() == null) {
csvLine[table.getIndex(CdmLightExportTable.DATE_PUBLISHED)] = inReference.getDatePublishedString();
csvLine[table.getIndex(CdmLightExportTable.YEAR_PUBLISHED)] = inReference.getDatePublished().getYear();
}
if (nomRef.getVolume() == null && inReference.getVolume() != null) {
csvLine[table.getIndex(CdmLightExportTable.VOLUME_ISSUE)] = inReference.getVolume();
csvLine[table.getIndex(CdmLightExportTable.COLLATION)] = createCollatation(name);
}
if (inReference.getInReference() != null) {
inReference = inReference.getInReference();
}
if (inReference.getAbbrevTitle() == null) {
csvLine[table.getIndex(CdmLightExportTable.ABBREV_TITLE)] = CdmUtils.Nz(inReference.getTitle());
} else {
csvLine[table.getIndex(CdmLightExportTable.ABBREV_TITLE)] = CdmUtils.Nz(inReference.getAbbrevTitle());
}
if (inReference.getTitle() == null) {
csvLine[table.getIndex(CdmLightExportTable.FULL_TITLE)] = CdmUtils.Nz(inReference.getAbbrevTitle() != null ? inReference.getAbbrevTitle() : inReference.getTitleCache());
} else {
csvLine[table.getIndex(CdmLightExportTable.FULL_TITLE)] = CdmUtils.Nz(inReference.getTitle());
}
TeamOrPersonBase<?> author = inReference.getAuthorship();
if (author != null && (nomRef.isOfType(ReferenceType.BookSection) || nomRef.isOfType(ReferenceType.Section))) {
csvLine[table.getIndex(CdmLightExportTable.ABBREV_REF_AUTHOR)] = author.isProtectedTitleCache() ? author.getTitleCache() : CdmUtils.Nz(author.getNomenclaturalTitleCache());
csvLine[table.getIndex(CdmLightExportTable.FULL_REF_AUTHOR)] = CdmUtils.Nz(author.getTitleCache());
} else {
csvLine[table.getIndex(CdmLightExportTable.ABBREV_REF_AUTHOR)] = "";
csvLine[table.getIndex(CdmLightExportTable.FULL_REF_AUTHOR)] = "";
}
} else {
if (nomRef.getAbbrevTitle() == null) {
csvLine[table.getIndex(CdmLightExportTable.ABBREV_TITLE)] = CdmUtils.Nz(nomRef.getTitle() != null ? nomRef.getTitle() : nomRef.getAbbrevTitleCache());
} else {
csvLine[table.getIndex(CdmLightExportTable.ABBREV_TITLE)] = CdmUtils.Nz(nomRef.getAbbrevTitle());
}
if (nomRef.getTitle() == null) {
csvLine[table.getIndex(CdmLightExportTable.FULL_TITLE)] = CdmUtils.Nz(nomRef.getAbbrevTitle() != null ? nomRef.getAbbrevTitle() : nomRef.getTitleCache());
} else {
csvLine[table.getIndex(CdmLightExportTable.FULL_TITLE)] = CdmUtils.Nz(nomRef.getTitle());
}
TeamOrPersonBase<?> author = nomRef.getAuthorship();
if (author != null) {
csvLine[table.getIndex(CdmLightExportTable.ABBREV_REF_AUTHOR)] = author.isProtectedTitleCache() ? author.getTitleCache() : CdmUtils.Nz(author.getNomenclaturalTitleCache());
csvLine[table.getIndex(CdmLightExportTable.FULL_REF_AUTHOR)] = CdmUtils.Nz(author.getTitleCache());
} else {
csvLine[table.getIndex(CdmLightExportTable.ABBREV_REF_AUTHOR)] = "";
csvLine[table.getIndex(CdmLightExportTable.FULL_REF_AUTHOR)] = "";
}
}
} else {
csvLine[table.getIndex(CdmLightExportTable.PUBLICATION_TYPE)] = "";
}
/*
* Collation
*
* Detail
*
* TitlePageYear
*/
String protologueUriString = extractProtologueURIs(state, name);
csvLine[table.getIndex(CdmLightExportTable.PROTOLOGUE_URI)] = protologueUriString;
Collection<TypeDesignationBase> specimenTypeDesignations = new ArrayList<>();
List<TextualTypeDesignation> textualTypeDesignations = new ArrayList<>();
for (TypeDesignationBase<?> typeDesignation : name.getTypeDesignations()) {
if (typeDesignation.isInstanceOf(TextualTypeDesignation.class)) {
if (((TextualTypeDesignation) typeDesignation).isVerbatim()) {
Set<IdentifiableSource> sources = typeDesignation.getSources();
boolean isProtologue = false;
if (sources != null && !sources.isEmpty()) {
IdentifiableSource source = sources.iterator().next();
if (name.getNomenclaturalReference() != null) {
isProtologue = source.getCitation() != null ? source.getCitation().getUuid().equals(name.getNomenclaturalReference().getUuid()) : false;
}
}
if (isProtologue) {
csvLine[table.getIndex(CdmLightExportTable.PROTOLOGUE_TYPE_STATEMENT)] = ((TextualTypeDesignation) typeDesignation).getPreferredText(Language.DEFAULT());
} else {
textualTypeDesignations.add((TextualTypeDesignation) typeDesignation);
}
} else {
textualTypeDesignations.add((TextualTypeDesignation) typeDesignation);
}
} else if (typeDesignation.isInstanceOf(SpecimenTypeDesignation.class)) {
SpecimenTypeDesignation specimenType = HibernateProxyHelper.deproxy(typeDesignation, SpecimenTypeDesignation.class);
specimenTypeDesignations.add(specimenType);
handleSpecimenType(state, specimenType);
} else if (typeDesignation instanceof NameTypeDesignation) {
specimenTypeDesignations.add(HibernateProxyHelper.deproxy(typeDesignation, NameTypeDesignation.class));
}
}
TypeDesignationSetManager manager = new TypeDesignationSetManager(specimenTypeDesignations, name);
HTMLTagRules rules = new HTMLTagRules();
rules.addRule(TagEnum.name, "i");
String test = manager.print(false, false, false, rules);
;
csvLine[table.getIndex(CdmLightExportTable.TYPE_SPECIMEN)] = manager.print(false, false, false, rules);
StringBuilder stringbuilder = new StringBuilder();
int i = 1;
for (TextualTypeDesignation typeDesignation : textualTypeDesignations) {
stringbuilder.append(typeDesignation.getPreferredText(Language.DEFAULT()));
if (typeDesignation.getSources() != null && !typeDesignation.getSources().isEmpty()) {
stringbuilder.append(" [");
int index = 1;
for (IdentifiableSource source : typeDesignation.getSources()) {
if (source.getCitation() != null) {
stringbuilder.append(OriginalSourceFormatter.INSTANCE.format(source));
}
if (index < typeDesignation.getSources().size()) {
stringbuilder.append(", ");
}
index++;
}
stringbuilder.append("]");
}
if (i < textualTypeDesignations.size()) {
stringbuilder.append("; ");
} else {
stringbuilder.append(".");
}
i++;
}
csvLine[table.getIndex(CdmLightExportTable.TYPE_STATEMENT)] = stringbuilder.toString();
if (name.getStatus() == null || name.getStatus().isEmpty()) {
csvLine[table.getIndex(CdmLightExportTable.NOM_STATUS)] = "";
csvLine[table.getIndex(CdmLightExportTable.NOM_STATUS_ABBREV)] = "";
} else {
String statusStringAbbrev = extractStatusString(state, name, true);
String statusString = extractStatusString(state, name, false);
csvLine[table.getIndex(CdmLightExportTable.NOM_STATUS)] = statusString.trim();
csvLine[table.getIndex(CdmLightExportTable.NOM_STATUS_ABBREV)] = statusStringAbbrev.trim();
}
HomotypicalGroup group = HibernateProxyHelper.deproxy(name.getHomotypicalGroup(), HomotypicalGroup.class);
csvLine[table.getIndex(CdmLightExportTable.HOMOTYPIC_GROUP_FK)] = getId(state, group);
List<TaxonName> typifiedNames = new ArrayList<>();
if (acceptedTaxon != null) {
HomotypicGroupTaxonComparator comparator = new HomotypicGroupTaxonComparator(acceptedTaxon);
List<Synonym> synonymsInGroup = null;
if (group.equals(acceptedTaxon.getHomotypicGroup())) {
synonymsInGroup = acceptedTaxon.getHomotypicSynonymsByHomotypicGroup(comparator);
typifiedNames.add(name);
} else {
synonymsInGroup = acceptedTaxon.getSynonymsInGroup(group, comparator);
}
synonymsInGroup.stream().forEach(synonym -> typifiedNames.add(HibernateProxyHelper.deproxy(synonym.getName(), TaxonName.class)));
} else {
typifiedNames.addAll(group.getTypifiedNames());
}
Integer seqNumber = typifiedNames.indexOf(name);
csvLine[table.getIndex(CdmLightExportTable.HOMOTYPIC_GROUP_SEQ)] = String.valueOf(seqNumber);
state.getProcessor().put(table, name, csvLine);
handleNameRelationships(state, name);
} catch (Exception e) {
state.getResult().addException(e, "An unexpected error occurred when handling the name " + cdmBaseStr(name) + ": " + name.getTitleCache() + ": " + e.getMessage());
e.printStackTrace();
}
}
use of eu.etaxonomy.cdm.model.name.NomenclaturalSource in project cdmlib by cybertaxonomy.
the class TaxonGraphBeforeTransactionCompleteProcess method doBeforeTransactionCompletion.
@Override
public void doBeforeTransactionCompletion(SessionImplementor session) {
if (logger.isDebugEnabled()) {
String message = eventType.name() + " for ";
message += taxonName != null ? taxonName.toString() : "";
message += nomenclaturalSource != null ? nomenclaturalSource.toString() : "";
if (eventType.equals(EventType.UPDATE)) {
message += " with dirty properties: " + Arrays.stream(dirtyProperties).mapToObj(i -> propertyNames[i]).collect(Collectors.joining(", "));
}
logger.debug(message);
}
try {
if (eventType.equals(EventType.INSERT)) {
// ---- INSERT ----
if (taxonName != null) {
// 1. do the sanity checks first
if (taxonName.getNomenclaturalSource() == null || taxonName.getNomenclaturalSource().getCitation() == null) {
if (failOnMissingNomRef) {
throw new TaxonGraphException("TaxonName.nomenclaturalSource or TaxonName.nomenclaturalSource.citation must never be null.");
} else {
logger.warn("TaxonName.nomenclaturalSource or TaxonName.nomenclaturalSource.citation must never be null. (" + taxonName.toString() + ")");
}
}
createTempSession(session);
onNewTaxonName(taxonName);
getSession().flush();
} else if (nomenclaturalSource != null) {
TaxonName taxonName = (TaxonName) findValueByName(state, NOMENCLATURALSOURCE_SOURCEDNAME);
Reference reference = (Reference) findValueByName(state, NOMENCLATURALSOURCE_CITATION);
if (taxonName != null && reference != null) {
createTempSession(session);
// load name and reference also into this session
taxonName = getSession().load(TaxonName.class, taxonName.getId());
reference = getSession().load(Reference.class, reference.getId());
onNewNomenClaturalSource(taxonName, reference);
getSession().flush();
}
}
} else if (eventType.equals(EventType.DELETE)) {
if (taxonName != null) {
// handling this case explicitly should not be needed as this is expected to be done by orphan removal in
// hibernate
Reference reference = (Reference) oldState[Arrays.binarySearch(propertyNames, TAXONNAME_NOMENCLATURALSOURCE)];
if (reference != null) {
createTempSession(session);
onTaxonNameDeleted(taxonName, reference);
getSession().flush();
}
} else if (nomenclaturalSource != null) {
TaxonName taxonName = (TaxonName) findValueByName(oldState, NOMENCLATURALSOURCE_SOURCEDNAME);
Reference reference = (Reference) findValueByName(oldState, NOMENCLATURALSOURCE_CITATION);
if (taxonName != null && reference != null) {
createTempSession(session);
onNomReferenceRemoved(taxonName, reference);
getSession().flush();
}
}
} else {
// either taxonName or nomenclaturalSource not null, never both!
if (taxonName != null) {
// 1. do the sanity checks first
Map<String, PropertyStateChange> changedNomenclaturalSourceProp = checkStateChange(TAXONNAME_NOMENCLATURALSOURCE);
if (!changedNomenclaturalSourceProp.isEmpty()) {
if (changedNomenclaturalSourceProp.get(TAXONNAME_NOMENCLATURALSOURCE[0]).newState == null) {
throw new TaxonGraphException("TaxonName.nomenclaturalSource must never be reverted to null.");
}
if (((NomenclaturalSource) changedNomenclaturalSourceProp.get(TAXONNAME_NOMENCLATURALSOURCE[0]).newState).getCitation() == null) {
throw new TaxonGraphException("TaxonName.nomenclaturalSource.citation must never be reverted to null.");
}
createTempSession(session);
NomenclaturalSource oldNomenclaturalSource = (NomenclaturalSource) changedNomenclaturalSourceProp.get(TAXONNAME_NOMENCLATURALSOURCE[0]).oldState;
onNomReferenceChange(taxonName, oldNomenclaturalSource.getCitation());
getSession().flush();
}
// 2. update the graph
Map<String, PropertyStateChange> changedProps = checkStateChange(TAXONNAME_NAMEPARTS_OR_RANK_PROPS);
if (!changedProps.isEmpty()) {
createTempSession(session);
onNameOrRankChange(taxonName);
getSession().flush();
}
} else if (nomenclaturalSource != null) {
Map<String, PropertyStateChange> changedProps = checkStateChange(CITATION_OR_SOURCEDNAME);
if (!changedProps.isEmpty()) {
TaxonName newTaxonNameState = null;
Reference newCitationState = null;
TaxonName oldTaxonNameState = null;
Reference oldCitationState = null;
if (changedProps.containsKey(NOMENCLATURALSOURCE_SOURCEDNAME)) {
newTaxonNameState = (TaxonName) changedProps.get(NOMENCLATURALSOURCE_SOURCEDNAME).newState;
oldTaxonNameState = (TaxonName) changedProps.get(NOMENCLATURALSOURCE_SOURCEDNAME).oldState;
}
if (changedProps.containsKey(NOMENCLATURALSOURCE_CITATION)) {
newCitationState = (Reference) changedProps.get(NOMENCLATURALSOURCE_CITATION).newState;
oldCitationState = (Reference) changedProps.get(NOMENCLATURALSOURCE_CITATION).oldState;
}
// 1. do the sanity checks first
if (oldTaxonNameState != null && oldTaxonNameState.getNomenclaturalSource() == null) {
createTempSession(session);
onNomReferenceChange(oldTaxonNameState, null);
getSession().flush();
}
// 2. update the graph
if (newTaxonNameState != null && newCitationState == null) {
createTempSession(session);
onNomReferenceChange(newTaxonNameState, nomenclaturalSource.getCitation());
getSession().flush();
}
if (newTaxonNameState == null && newCitationState != null) {
createTempSession(session);
onNomReferenceChange(nomenclaturalSource.getSourcedName(), oldCitationState);
getSession().flush();
}
}
}
}
} catch (TaxonGraphException e) {
throw new HibernateException(e);
} finally {
if (getSession() != null) {
// temporarySession.close(); // no need to close the session since the session is configured for auto close, see createTempSession()
if (origLoggerLevel != null) {
Logger.getLogger("org.hibernate.SQL").setLevel(origLoggerLevel);
}
}
}
}
use of eu.etaxonomy.cdm.model.name.NomenclaturalSource in project cdmlib by cybertaxonomy.
the class TaxonGraphHibernateListener method onPostUpdate.
@Override
public void onPostUpdate(PostUpdateEvent event) {
if (event.getEntity() instanceof TaxonName || event.getEntity() instanceof NomenclaturalSource) {
for (Class<? extends BeforeTransactionCompletionProcess> type : beforeTransactionCompletionProcessTypes.keySet()) {
try {
ProcessConstructorData<? extends BeforeTransactionCompletionProcess> pcd = beforeTransactionCompletionProcessTypes.get(type);
BeforeTransactionCompletionProcess processorInstance = pcd.postUpdateEventConstructor.newInstance(pcd.buildConstructorArgs(event));
event.getSession().getActionQueue().registerProcess(processorInstance);
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | SecurityException e) {
Logger.getLogger(TaxonGraphHibernateListener.class).error("Error creating new instance of " + type.toString(), e);
}
}
}
}
use of eu.etaxonomy.cdm.model.name.NomenclaturalSource in project cdmlib by cybertaxonomy.
the class TaxonGraphHibernateListener method onPostInsert.
@Override
public void onPostInsert(PostInsertEvent event) {
if (event.getEntity() instanceof TaxonName || event.getEntity() instanceof NomenclaturalSource) {
for (Class<? extends BeforeTransactionCompletionProcess> type : beforeTransactionCompletionProcessTypes.keySet()) {
try {
ProcessConstructorData<? extends BeforeTransactionCompletionProcess> pcd = beforeTransactionCompletionProcessTypes.get(type);
BeforeTransactionCompletionProcess processorInstance = pcd.postInsertEventConstructor.newInstance(pcd.buildConstructorArgs(event));
event.getSession().getActionQueue().registerProcess(processorInstance);
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | SecurityException e) {
Logger.getLogger(TaxonGraphHibernateListener.class).error("Error creating new instance of " + type.toString(), e);
}
}
}
}
Aggregations