001/* 002 * (C) Copyright 2016 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Florent Guillaume 018 */ 019package org.nuxeo.ecm.core.storage.dbs; 020 021import java.util.ArrayList; 022import java.util.HashSet; 023import java.util.List; 024import java.util.Set; 025 026import org.nuxeo.common.xmap.annotation.XNode; 027import org.nuxeo.common.xmap.annotation.XNodeList; 028import org.nuxeo.ecm.core.storage.FulltextDescriptor; 029import org.nuxeo.ecm.core.storage.FulltextDescriptor.FulltextIndexDescriptor; 030 031/** 032 * DBS Repository Descriptor. 033 * 034 * @since 7.10-HF04, 8.1 035 */ 036public class DBSRepositoryDescriptor implements Cloneable { 037 038 public DBSRepositoryDescriptor() { 039 } 040 041 @XNode("@name") 042 public String name; 043 044 @XNode("@label") 045 public String label; 046 047 @XNode("@isDefault") 048 protected Boolean isDefault; 049 050 public Boolean isDefault() { 051 return isDefault; 052 } 053 054 protected FulltextDescriptor fulltextDescriptor = new FulltextDescriptor(); 055 056 public FulltextDescriptor getFulltextDescriptor() { 057 return fulltextDescriptor; 058 } 059 060 @XNode("fulltext@disabled") 061 public void setFulltextDisabled(boolean disabled) { 062 fulltextDescriptor.setFulltextDisabled(disabled); 063 } 064 065 @XNode("fulltext@searchDisabled") 066 public void setFulltextSearchDisabled(boolean disabled) { 067 fulltextDescriptor.setFulltextSearchDisabled(disabled); 068 } 069 070 @XNode("fulltext@parser") 071 public void setFulltextParser(String fulltextParser) { 072 fulltextDescriptor.setFulltextParser(fulltextParser); 073 } 074 075 @XNodeList(value = "fulltext/index", type = ArrayList.class, componentType = FulltextIndexDescriptor.class) 076 public void setFulltextIndexes(List<FulltextIndexDescriptor> fulltextIndexes) { 077 fulltextDescriptor.setFulltextIndexes(fulltextIndexes); 078 } 079 080 @XNodeList(value = "fulltext/excludedTypes/type", type = HashSet.class, componentType = String.class) 081 public void setFulltextExcludedTypes(Set<String> fulltextExcludedTypes) { 082 fulltextDescriptor.setFulltextExcludedTypes(fulltextExcludedTypes); 083 } 084 085 @XNodeList(value = "fulltext/includedTypes/type", type = HashSet.class, componentType = String.class) 086 public void setFulltextIncludedTypes(Set<String> fulltextIncludedTypes) { 087 fulltextDescriptor.setFulltextIncludedTypes(fulltextIncludedTypes); 088 } 089 090 @Override 091 public DBSRepositoryDescriptor clone() { 092 try { 093 DBSRepositoryDescriptor clone = (DBSRepositoryDescriptor) super.clone(); 094 clone.fulltextDescriptor = new FulltextDescriptor(fulltextDescriptor); 095 return clone; 096 } catch (CloneNotSupportedException e) { // cannot happen 097 throw new RuntimeException(e); 098 } 099 } 100 101 public void merge(DBSRepositoryDescriptor other) { 102 if (other.name != null) { 103 name = other.name; 104 } 105 if (other.label != null) { 106 label = other.label; 107 } 108 if (other.isDefault != null) { 109 isDefault = other.isDefault; 110 } 111 fulltextDescriptor.merge(other.fulltextDescriptor); 112 } 113 114}