| /******************************************************************************* |
| * Copyright (c) 2004-2008 Andras Balogh and Daniel Varro |
| * 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: |
| * Andras Balogh - initial API and implementation |
| *******************************************************************************/ |
| |
| package org.eclipse.viatra2.imports.vtml;
|
|
|
| import org.eclipse.viatra2.core.IModelSpace; |
| import org.eclipse.viatra2.core.IRelation; |
| import org.eclipse.viatra2.errors.VPMCoreException; |
|
|
| public class InverseDefinition extends RelationshipDefinition{
|
|
|
|
|
| public InverseDefinition(int l, String ns, String n, String s)
|
| {
|
| super(l,ns,n,s);
|
|
|
|
|
| }
|
| @Override
|
| public boolean checkDefintion(ASTBuilder ab, IModelSpace m) {
|
| // TODO Auto-generated method stub
|
| boolean tmp = super.checkDefintion(ab, m);
|
| if (tmp)
|
| {
|
| if (_mstr instanceof EntityDefinition)
|
| {
|
| ab.log.error("Inverse relationship can only be specified between relations. Error in line "+getLine());
|
| return false;
|
| }
|
| if (_slv instanceof EntityDefinition)
|
| {
|
| ab.log.error("Inverse relationship can only be specified between relations. Error in line "+getLine());
|
| return false;
|
| }
|
| }
|
| return tmp;
|
| }
|
|
|
| @Override
|
| public void resolveReferences(ASTBuilder ab) throws VPMCoreException {
|
|
|
| ab.mm.setRelationInverse((IRelation)_mstr.getElement(),(IRelation)_slv.getElement());
|
| ab.mm.setRelationInverse((IRelation)_slv.getElement(),(IRelation)_mstr.getElement());
|
|
|
| }
|
| }
|