001package com.astrolabsoftware.FinkBrowser.Januser;
002
003import com.Lomikel.Januser.Hertex;
004
005// Tinker Pop
006import org.apache.tinkerpop.gremlin.structure.Vertex;
007import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
008
009// Log4J
010import org.apache.logging.log4j.Logger;
011import org.apache.logging.log4j.LogManager;
012
013/** <code>Alert</code> is a {@link Hertex} representing <em>alert</em>.
014  * @opt attributes
015  * @opt operations
016  * @opt types
017  * @opt visibility
018  * @author <a href="mailto:Julius.Hrivnac@cern.ch">J.Hrivnac</a> */
019public class Alert extends Hertex {
020   
021  static {
022    setRowkeyName("alert", Alert.class, "rowkey");
023    }
024
025  /** Dress existing {@link Vertex} with values from HBase.
026    * @param vertex The original {@link Vertex}.
027    * @param fields The coma-separated list of fields to fill in from the database.
028    *               All fields will be filled in if <tt>null</tt>. */
029  public Alert(Vertex vertex,
030               String fields) {
031    super(vertex, fields);
032    }
033   
034  /** Dress existing {@link Vertex} with values from HBase.
035    * @param vertex The original {@link Vertex}.
036    * @param fields The fields to fill in from the database.
037    *               All fields will be filled in if <tt>null</tt>. */
038  public Alert(Vertex   vertex,
039               String[] fields) {
040    super(vertex, fields);
041    }
042    
043  /** Get {@link Alert} backuped by <em>HBase</em>
044    * from the <em>JanusGraph</em>, or create if it doesn't exist yet.
045    * @param rowkey  The {@link Vertex} <tt>rowkey</tt> value.
046    * @param g       The {@link GraphTraversalSource} to be used to execute operations.
047    * @param fields  The coma-separated list of fields to fill.
048    *                <tt>null</tt> will fill all fields.
049    *                Empty String will fill nothing besides rowkey fields.
050    * @return        The created {@link Vertex}. It will be created even when no corresponding
051    *                entry exists in the <em>HBase</em>. In that case, it can be enhanced later. */
052  public static Vertex getOrCreate(String                 rowkey,
053                                   GraphTraversalSource   g,
054                                   String                 fields) {
055    return Hertex.getOrCreate("alert", rowkey, g, fields).get(0);
056    }
057    
058  /** Get {@link Alert} backuped by <em>HBase</em>
059    * from the <em>JanusGraph</em>, or create if it doesn't exist yet.
060    * @param rowkey  The {@link Vertex} <tt>rowkey</tt> value.
061    * @param g       The {@link GraphTraversalSource} to be used to execute operations.
062    * @param enhance Whether enhance all values from the <em>HBase</em>.
063    * @return        The created {@link Vertex}. It will be created even when no corresponding
064    *                entry exists in the <em>HBase</em>. In that case, it can be enhanced later. */
065  public static Vertex getOrCreate(String                 rowkey,
066                                   GraphTraversalSource   g,
067                                   boolean                enhance) {
068    return Hertex.getOrCreate("alert", rowkey, g, enhance).get(0);
069    }
070        
071  /** Logging . */
072  private static Logger log = LogManager.getLogger(Alert.class);
073
074  }