Mercurial > hg > ismi-richfaces
changeset 126:29d40186dfd7
try to fix disappearing alias attribute.
author | casties |
---|---|
date | Wed, 01 Feb 2017 18:07:00 +0100 |
parents | eee2e0ca4032 |
children | efeab3bd856f |
files | src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentPersonBean.java |
diffstat | 1 files changed, 20 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentPersonBean.java Tue Jan 31 18:09:54 2017 +0100 +++ b/src/main/java/de/mpiwg/itgroup/ismi/entry/beans/CurrentPersonBean.java Wed Feb 01 18:07:00 2017 +0100 @@ -139,19 +139,17 @@ String newShortName = (String) event.getNewValue(); if (shortNameAlias == null) { - shortNameAlias = new Entity(org.mpi.openmind.repository.bo.Node.TYPE_ABOX, ALIAS, false); - + shortNameAlias = new Entity(Node.TYPE_ABOX, ALIAS, false); } - Attribute attr = this.shortNameAlias.getAttributeByName(alias); + Attribute attr = shortNameAlias.getAttributeByName(alias); if (attr == null) { - this.shortNameAlias.addAttribute(new Attribute(alias, TEXT, - newShortName)); - } else + shortNameAlias.addAttribute(new Attribute(alias, TEXT, newShortName)); + } else { attr.setValue(newShortName); - + } } catch (Exception e) { - e.printStackTrace(); + logger.error(e); } } @@ -272,14 +270,6 @@ // PERSON -> was_died_in -> PLACE replaceAliasSourceRelation(this.entity, deathPlaceLo, PLACE, "died_in", "died_in_as"); - // ALIAS -> is_prime_alias_name_of -> PERSON - this.entity.removeAllTargetRelationsByName(is_prime_alias_name_of); - if (shortNameAlias != null) { - shortNameAlias.setObjectClass(ALIAS); - shortNameAlias = getWrapper().saveEntity(shortNameAlias, getSessionUser().getEmail(), null); - new Relation(shortNameAlias, this.entity, is_alias_name_of); - } - // ALIAS -> is_alias_name_of -> PERSON this.entity.removeAllTargetRelationsByName(is_alias_name_of); for(Entity alias : this.aliasList.getEntities()){ @@ -287,6 +277,20 @@ new Relation(alias0, this.entity, is_alias_name_of); } + // ALIAS -> is_prime_alias_name_of/is_alias_name_of -> PERSON + this.entity.removeAllTargetRelationsByName(is_prime_alias_name_of); + if (shortNameAlias != null) { + if (shortNameAlias.getAttributeByName(alias) == null) { + logger.error("ALIAS without Attribute!"); + if (valueShortName != null) { + shortNameAlias.addAttribute(new Attribute(alias, TEXT, valueShortName)); + } + } + shortNameAlias = getWrapper().saveEntity(shortNameAlias, getSessionUser().getEmail(), null); + // save as is_alias_name_of + new Relation(shortNameAlias, this.entity, is_alias_name_of); + } + // PERSON -> lived_in -> PLACE (manyToMany) this.entity.removeAllSourceRelationsByName(lived_in); this.entity.removeAllSourceRelationsByName(lived_in_as);