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