X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.db.layer0%2Fsrc%2Forg%2Fsimantics%2Fdb%2Flayer0%2Fadapter%2Fimpl%2FRelatedEntityNameModifier.java;h=cc1f7bae4022eec650655ebfdad3958556aad503;hb=3c524553c98b56075d854f355bc7bab2e3ae17f7;hp=8526918a6eb097783206226fa09ed81ba152f6a9;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/adapter/impl/RelatedEntityNameModifier.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/adapter/impl/RelatedEntityNameModifier.java index 8526918a6..cc1f7bae4 100644 --- a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/adapter/impl/RelatedEntityNameModifier.java +++ b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/adapter/impl/RelatedEntityNameModifier.java @@ -1,63 +1,63 @@ -/******************************************************************************* - * Copyright (c) 2014 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Semantum Oy - initial API and implementation - *******************************************************************************/ -package org.simantics.db.layer0.adapter.impl; - -import org.simantics.databoard.Bindings; -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.WriteGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.db.layer0.adapter.StringModifier; -import org.simantics.layer0.Layer0; - -/** - * A modifier that enforces all the same naming validations as - * {@link EntityNameModifier} but also makes sure that entities directly related - * to the specified entity with the specified relation are renamed at the same - * time. - * - * @author Tuukka Lehtonen - * @see EntityNameModifier - */ -public final class RelatedEntityNameModifier implements StringModifier { - - private EntityNameModifier entityModifier; - private Resource entity; - private Resource relation; - - public RelatedEntityNameModifier(ReadGraph graph, Resource entity, Resource property, Resource relation) throws DatabaseException { - this.entityModifier = new EntityNameModifier(graph, entity, property); - this.entity = entity; - this.relation = relation; - } - - @Override - public String getValue() { - return entityModifier.getValue(); - } - - @Override - public String isValid(String value) { - return entityModifier.isValid(value); - } - - @Override - final public void modify(WriteGraph graph, String value) throws DatabaseException { - entityModifier.modify(graph, value); - - Layer0 L0 = Layer0.getInstance(graph); - String v = entityModifier.finalValue(value); - for (Resource related : graph.getObjects(entity, relation)) - graph.claimLiteral(related, L0.HasName, L0.NameOf, v, Bindings.STRING); - } - -} +/******************************************************************************* + * Copyright (c) 2014 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Semantum Oy - initial API and implementation + *******************************************************************************/ +package org.simantics.db.layer0.adapter.impl; + +import org.simantics.databoard.Bindings; +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.WriteGraph; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.adapter.StringModifier; +import org.simantics.layer0.Layer0; + +/** + * A modifier that enforces all the same naming validations as + * {@link EntityNameModifier} but also makes sure that entities directly related + * to the specified entity with the specified relation are renamed at the same + * time. + * + * @author Tuukka Lehtonen + * @see EntityNameModifier + */ +public final class RelatedEntityNameModifier implements StringModifier { + + private EntityNameModifier entityModifier; + private Resource entity; + private Resource relation; + + public RelatedEntityNameModifier(ReadGraph graph, Resource entity, Resource property, Resource relation) throws DatabaseException { + this.entityModifier = new EntityNameModifier(graph, entity, property); + this.entity = entity; + this.relation = relation; + } + + @Override + public String getValue() { + return entityModifier.getValue(); + } + + @Override + public String isValid(String value) { + return entityModifier.isValid(value); + } + + @Override + final public void modify(WriteGraph graph, String value) throws DatabaseException { + entityModifier.modify(graph, value); + + Layer0 L0 = Layer0.getInstance(graph); + String v = entityModifier.finalValue(value); + for (Resource related : graph.getObjects(entity, relation)) + graph.claimLiteral(related, L0.HasName, L0.NameOf, v, Bindings.STRING); + } + +}