| /** |
| * |
| * Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany) |
| * |
| * 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: |
| * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation |
| * |
| * |
| * This copyright notice shows up in the generated Java code |
| * |
| */ |
| |
| package org.eclipse.osbp.xtext.topologydsl.validation |
| |
| import org.eclipse.osbp.xtext.datamartdsl.EventBrokerDataMart |
| import org.eclipse.osbp.xtext.topologydsl.Topology |
| import org.eclipse.osbp.xtext.topologydsl.TopologyDSLPackage |
| import java.util.List |
| import org.eclipse.xtext.validation.Check |
| |
| //import org.eclipse.xtext.validation.Check |
| |
| /** |
| * Custom validation rules. |
| * |
| * see http://www.eclipse.org/Xtext/documentation.html#validation |
| */ |
| class TopologyDSLValidator extends AbstractTopologyDSLValidator { |
| |
| // public static val INVALID_NAME = 'invalidName' |
| // |
| // @Check |
| // def checkGreetingStartsWithCapital(Greeting greeting) { |
| // if (!Character.isUpperCase(greeting.name.charAt(0))) { |
| // warning('Name should start with a capital', |
| // MyDslPackage.Literals.GREETING__NAME, |
| // INVALID_NAME) |
| // } |
| // } |
| |
| @Check |
| def void checkDuplicateDatamartFilters(Topology topology) { |
| var usedFilterMap = <String, List<String>>newHashMap() |
| for (dat : topology.datamarts) { |
| if (dat!=null && dat.datamartDef!=null){ |
| var usedFilter = usedFilterMap.get(dat.datamartDef.name) |
| if (usedFilter == null){ |
| usedFilter = <String>newArrayList() |
| } |
| // Check that no duplicate filters within a datamart is defined |
| if (usedFilter.contains(dat.filter)){ |
| error('Duplicate filter: '.concat(dat.datamartDef.name), dat, TopologyDSLPackage.Literals.TOPOLOGY_BASE__NAME) |
| } else { |
| usedFilter.add(dat.filter) |
| usedFilterMap.put(dat.datamartDef.name, usedFilter) |
| } |
| } |
| } |
| } |
| |
| } |