package com.mjm.solarInsertDB;

import javax.baja.nre.annotations.NiagaraProperty;
import javax.baja.nre.annotations.NiagaraType;
import javax.baja.sys.*;

/**
 * Created by Huliang and jiahao on 2025/03/05.
 */
@NiagaraType
//@NiagaraProperty(name = "insertToDatabase", type = "boolean", defaultValue = "true",flags =Flags.SUMMARY )
@NiagaraProperty(name = "dbIp", type = "BString", defaultValue = "127.0.0.1",flags =Flags.SUMMARY )
@NiagaraProperty(name = "dbName", type = "BString", defaultValue = "center",flags =Flags.SUMMARY )
@NiagaraProperty(name = "dbUser", type = "BString", defaultValue = "sa",flags =Flags.SUMMARY )
@NiagaraProperty(name = "dbPassword", type = "BString", defaultValue = "123456",flags =Flags.SUMMARY )
@NiagaraProperty(name = "dbTableName", type = "BString", defaultValue = "",flags =Flags.SUMMARY )
public class BDatabaseInformation extends BComponent {
/*+ ------------ BEGIN BAJA AUTO GENERATED CODE ------------ +*/
/*@ $com.mjm.solarInsertDB.BDatabaseInformation(1329227581)1.0$ @*/
/* Generated Mon Mar 24 23:40:56 CST 2025 by Slot-o-Matic (c) Tridium, Inc. 2012 */

////////////////////////////////////////////////////////////////
// Property "dbIp"
////////////////////////////////////////////////////////////////
  
  /**
   * Slot for the {@code dbIp} property.
   * @see #getDbIp
   * @see #setDbIp
   */
  public static final Property dbIp = newProperty(Flags.SUMMARY, "127.0.0.1", null);
  
  /**
   * Get the {@code dbIp} property.
   * @see #dbIp
   */
  public String getDbIp() { return getString(dbIp); }
  
  /**
   * Set the {@code dbIp} property.
   * @see #dbIp
   */
  public void setDbIp(String v) { setString(dbIp, v, null); }

////////////////////////////////////////////////////////////////
// Property "dbName"
////////////////////////////////////////////////////////////////
  
  /**
   * Slot for the {@code dbName} property.
   * @see #getDbName
   * @see #setDbName
   */
  public static final Property dbName = newProperty(Flags.SUMMARY, "center", null);
  
  /**
   * Get the {@code dbName} property.
   * @see #dbName
   */
  public String getDbName() { return getString(dbName); }
  
  /**
   * Set the {@code dbName} property.
   * @see #dbName
   */
  public void setDbName(String v) { setString(dbName, v, null); }

////////////////////////////////////////////////////////////////
// Property "dbUser"
////////////////////////////////////////////////////////////////
  
  /**
   * Slot for the {@code dbUser} property.
   * @see #getDbUser
   * @see #setDbUser
   */
  public static final Property dbUser = newProperty(Flags.SUMMARY, "sa", null);
  
  /**
   * Get the {@code dbUser} property.
   * @see #dbUser
   */
  public String getDbUser() { return getString(dbUser); }
  
  /**
   * Set the {@code dbUser} property.
   * @see #dbUser
   */
  public void setDbUser(String v) { setString(dbUser, v, null); }

////////////////////////////////////////////////////////////////
// Property "dbPassword"
////////////////////////////////////////////////////////////////
  
  /**
   * Slot for the {@code dbPassword} property.
   * @see #getDbPassword
   * @see #setDbPassword
   */
  public static final Property dbPassword = newProperty(Flags.SUMMARY, "123456", null);
  
  /**
   * Get the {@code dbPassword} property.
   * @see #dbPassword
   */
  public String getDbPassword() { return getString(dbPassword); }
  
  /**
   * Set the {@code dbPassword} property.
   * @see #dbPassword
   */
  public void setDbPassword(String v) { setString(dbPassword, v, null); }

////////////////////////////////////////////////////////////////
// Property "dbTableName"
////////////////////////////////////////////////////////////////
  
  /**
   * Slot for the {@code dbTableName} property.
   * @see #getDbTableName
   * @see #setDbTableName
   */
  public static final Property dbTableName = newProperty(Flags.SUMMARY, "", null);
  
  /**
   * Get the {@code dbTableName} property.
   * @see #dbTableName
   */
  public String getDbTableName() { return getString(dbTableName); }
  
  /**
   * Set the {@code dbTableName} property.
   * @see #dbTableName
   */
  public void setDbTableName(String v) { setString(dbTableName, v, null); }

////////////////////////////////////////////////////////////////
// Type
////////////////////////////////////////////////////////////////
  
  @Override
  public Type getType() { return TYPE; }
  public static final Type TYPE = Sys.loadType(BDatabaseInformation.class);

/*+ ------------ END BAJA AUTO GENERATED CODE -------------- +*/



    public void changed(Property property, Context context) {
        if (this.isRunning()) {
            System.out.println("DB information changed");
            BInsertData InsertData = (BInsertData)this.getParent().asComponent();
            InsertData.setDatabaseInformation();
        }
    }
}
