--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.server.cluster;
+
+import java.io.Serializable;
+
+
+public interface WorkQueue {
+
+ Integer enqueInsert(String indexName, Serializable key);
+
+ Integer enqueUpdate(String indexName, Serializable key);
+
+ Integer enqueDelete(String indexName, Serializable key);
+
+ Serializable dequeInsert(String indexName);
+
+ Serializable dequeUpdate(String indexName);
+
+ Serializable dequeDelete(String indexName);
+
+ Status getStatus(Integer workId);
+
+ interface Status {
+
+ }
+}
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.server.db;
+
+import java.io.Serializable;
+
+public interface Dao<E extends Dto<K>, K extends Serializable> {
+
+ public E getByKey(K key);
+
+ public E update(E item);
+
+ public E insert(E item);
+
+ public void delete(E item);
+
+ public void deleteByKey(K key);
+
+}
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.server.db;
+
+import java.io.Serializable;
+
+public interface Dto<K extends Serializable> {
+
+ K getKey();
+
+}
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.server.search;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+public class Hit implements Comparable<Hit> {
+
+ private Map<String, Collection<Serializable>> fields;
+
+ private Integer rank;
+
+ public Hit(Integer rank){
+ this.fields = new HashMap<String, Collection<Serializable>>();
+ this.rank = rank;
+ }
+
+ public Collection<Serializable> getFieldValues(String field){
+ return this.fields.get(field);
+ }
+
+ public Serializable getFieldValue(String field){
+ if(this.hasField(field)){
+ return fields.get(field).iterator().next();
+ } else {
+ return null;
+ }
+ }
+
+ public Hit addFieldValue(String field, Serializable value){
+ if(!this.hasField(field)){
+ this.fields.put(field, new ArrayList<Serializable>());
+ }
+ return this;
+ }
+
+ public boolean hasField(String field){
+ return this.fields.containsKey(field) &&
+ !this.fields.get(field).isEmpty();
+ }
+
+ public Integer getRank(){
+ return this.rank;
+ }
+
+ @Override
+ public int compareTo(Hit hit) {
+ return this.getRank().compareTo(hit.getRank());
+ }
+}
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.server.search;
+
+import org.picocontainer.Startable;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.Date;
+import java.util.Map;
+
+public interface Index<K extends Serializable> extends Startable {
+
+ Hit getByKey(K key);
+
+ void insert(K key);
+
+ void udpate(K key);
+
+ void delete(K key);
+
+ K dequeueInsert();
+
+ K dequeueUpdate();
+
+ K dequeueDelete();
+
+ Map<String, Object> normalize(K key);
+
+ Date getLastSynchronization();
+
+ Collection<K> synchronizeSince(Date date);
+}