001/*
002 * Copyright (c) 2006-2014 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 *     Florent Guillaume
011 */
012package org.nuxeo.ecm.core.storage.mongodb;
013
014import org.nuxeo.common.xmap.annotation.XNode;
015import org.nuxeo.common.xmap.annotation.XObject;
016
017/**
018 * MongoDB Repository Descriptor.
019 */
020@XObject(value = "repository")
021public class MongoDBRepositoryDescriptor {
022
023    public MongoDBRepositoryDescriptor() {
024    }
025
026    /** False if the boolean is null or FALSE, true otherwise. */
027    private static boolean defaultFalse(Boolean bool) {
028        return Boolean.TRUE.equals(bool);
029    }
030
031    @XNode("@name")
032    public String name;
033
034    @XNode("@label")
035    public String label;
036
037    @XNode("@isDefault")
038    private Boolean isDefault;
039
040    public Boolean isDefault() {
041        return isDefault;
042    }
043
044    @XNode("fulltext@disabled")
045    private Boolean fulltextDisabled;
046
047    public boolean getFulltextDisabled() {
048        return defaultFalse(fulltextDisabled);
049    }
050
051    // ----- MongoDB specific options -----
052
053    @XNode("server")
054    public String server;
055
056    @XNode("dbname")
057    public String dbname;
058
059    /** Copy constructor. */
060    public MongoDBRepositoryDescriptor(MongoDBRepositoryDescriptor other) {
061        name = other.name;
062        label = other.label;
063        isDefault = other.isDefault;
064        server = other.server;
065        dbname = other.dbname;
066        fulltextDisabled = other.fulltextDisabled;
067    }
068
069    public void merge(MongoDBRepositoryDescriptor other) {
070        if (other.name != null) {
071            name = other.name;
072        }
073        if (other.label != null) {
074            label = other.label;
075        }
076        if (other.isDefault != null) {
077            isDefault = other.isDefault;
078        }
079        if (other.server != null) {
080            server = other.server;
081        }
082        if (other.dbname != null) {
083            dbname = other.dbname;
084        }
085        if (other.fulltextDisabled != null) {
086            fulltextDisabled = other.fulltextDisabled;
087        }
088    }
089
090}