001/* 002 * Copyright (c) 2006-2011 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the Eclipse Public License v1.0 006 * which accompanies this distribution, and is available at 007 * http://www.eclipse.org/legal/epl-v10.html 008 * 009 * Contributors: 010 * bstefanescu 011 */ 012package org.nuxeo.ecm.automation.client.model; 013 014import java.io.Serializable; 015import java.util.HashMap; 016import java.util.Map; 017 018/** 019 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a> 020 */ 021public class OperationRegistry implements Serializable { 022 023 private static final long serialVersionUID = 7052919017498723129L; 024 025 protected Map<String, String> paths; 026 027 protected Map<String, OperationDocumentation> ops; 028 029 protected Map<String, OperationDocumentation> chains; 030 031 public OperationRegistry(Map<String, String> paths, Map<String, OperationDocumentation> ops, 032 Map<String, OperationDocumentation> chains) { 033 this.ops = ops; 034 this.chains = chains; 035 this.paths = paths; 036 } 037 038 public String getPath(String key) { 039 return paths.get(key); 040 } 041 042 public OperationDocumentation getOperation(String key) { 043 OperationDocumentation op = ops.get(key); 044 if (op == null) { 045 op = chains.get(key); 046 } 047 return op; 048 } 049 050 public Map<String, OperationDocumentation> getOperations() { 051 Map<String, OperationDocumentation> map = new HashMap<String, OperationDocumentation>(ops); 052 map.putAll(chains); 053 return map; 054 } 055}