1 /*******************************************************************************
\r
2 * Copyright (c) 2013 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * Semantum Oy - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.db.layer0.adapter.impl;
\r
14 import org.simantics.db.ReadGraph;
\r
15 import org.simantics.db.Resource;
\r
16 import org.simantics.db.exception.DatabaseException;
\r
17 import org.simantics.db.layer0.adapter.StringModifier;
\r
18 import org.simantics.db.layer0.adapter.StringModifierFactory;
\r
19 import org.simantics.db.layer0.variable.Variable;
\r
20 import org.simantics.layer0.Layer0;
\r
23 * Makes sure that two things apply for L0.HasName of any entity:
\r
25 * <li>An entity must not have the same name as any of its
\r
26 * L0.PartOf/L0.ConsistsOf related siblings</li>
\r
27 * <li>An entity's name must not begin with one or more dots ('.'). Due to
\r
28 * limitations imposed by the Variable specification no resources in the
\r
29 * simantics database should be named beginning with one or more dots. '.' is
\r
30 * variable browsing syntax for "parent" (see
\r
31 * {@link Variable#browse(ReadGraph, String)}). This is comparable to file
\r
32 * systems and the use of '.' and '..' therein.</li>
\r
35 * @author Tuukka Lehtonen
\r
37 public final class EntityStringModifierFactory implements StringModifierFactory {
\r
39 private Resource subject;
\r
41 public EntityStringModifierFactory(Resource subject) throws DatabaseException {
\r
42 this.subject = subject;
\r
46 public StringModifier createModifier(ReadGraph graph, Resource relation, Resource property) throws DatabaseException {
\r
47 Layer0 L0 = Layer0.getInstance(graph);
\r
49 // Names require special care in validation.
\r
50 if (L0.HasName.equals(relation)) {
\r
51 return new EntityNameModifier(graph, subject, property);
\r