edu.internet2.middleware.grouper.dataField.GrouperDataRowAssign Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of grouper Show documentation
Show all versions of grouper Show documentation
Internet2 Groups Management Toolkit
package edu.internet2.middleware.grouper.dataField;
import java.sql.Timestamp;
import edu.internet2.middleware.grouper.tableIndex.TableIndex;
import edu.internet2.middleware.grouper.tableIndex.TableIndexType;
import edu.internet2.middleware.grouperClient.jdbc.GcDbVersionable;
import edu.internet2.middleware.grouperClient.jdbc.GcPersist;
import edu.internet2.middleware.grouperClient.jdbc.GcPersistableClass;
import edu.internet2.middleware.grouperClient.jdbc.GcPersistableField;
import edu.internet2.middleware.grouperClient.jdbc.GcSqlAssignPrimaryKey;
import edu.internet2.middleware.grouperClient.util.GrouperClientUtils;
import org.apache.commons.lang3.builder.EqualsBuilder;
/**
* loader config for grouper data row assign
*/
@GcPersistableClass(tableName="grouper_data_row_assign", defaultFieldPersist=GcPersist.doPersist)
public class GrouperDataRowAssign implements GcSqlAssignPrimaryKey, GcDbVersionable {
private long dataRowInternalId = -1;
private long memberInternalId = -1;
@GcPersistableField(primaryKey=true, primaryKeyManuallyAssigned=true)
private long internalId = -1;
private Timestamp createdOn = null;
private long dataProviderInternalId;
/**
* version from db
*/
@GcPersistableField(persist = GcPersist.dontPersist)
private GrouperDataRowAssign dbVersion;
public long getInternalId() {
return internalId;
}
public void setInternalId(long internalId) {
this.internalId = internalId;
}
public Timestamp getCreatedOn() {
return createdOn;
}
public void setCreatedOn(Timestamp createdOn) {
this.createdOn = createdOn;
}
public long getDataRowInternalId() {
return dataRowInternalId;
}
public void setDataRowInternalId(long dataRowInternalId) {
this.dataRowInternalId = dataRowInternalId;
}
public long getMemberInternalId() {
return memberInternalId;
}
public void setMemberInternalId(long memberInternalId) {
this.memberInternalId = memberInternalId;
}
public long getDataProviderInternalId() {
return dataProviderInternalId;
}
public void setDataProviderInternalId(long dataProviderInternalId) {
this.dataProviderInternalId = dataProviderInternalId;
}
/**
*
*/
@Override
public boolean gcSqlAssignNewPrimaryKeyForInsert() {
if (this.internalId != -1) {
return false;
}
this.internalId = TableIndex.reserveId(TableIndexType.dataRowAssign);
return true;
}
//########## END GENERATED BY GcDbVersionableGenerate.java ###########
/**
* deep clone the fields in this object
*/
@Override
public GrouperDataRowAssign clone() {
GrouperDataRowAssign grouperDataRowAssign = new GrouperDataRowAssign();
//dbVersion DONT CLONE
grouperDataRowAssign.createdOn = this.createdOn;
grouperDataRowAssign.dataProviderInternalId = this.dataProviderInternalId;
grouperDataRowAssign.dataRowInternalId = this.dataRowInternalId;
grouperDataRowAssign.internalId = this.internalId;
grouperDataRowAssign.memberInternalId = this.memberInternalId;
return grouperDataRowAssign;
}
/**
* db version
*/
@Override
public void dbVersionDelete() {
this.dbVersion = null;
}
/**
* if we need to update this object
* @return if needs to update this object
*/
@Override
public boolean dbVersionDifferent() {
return !this.equalsDeep(this.dbVersion);
}
/**
* take a snapshot of the data since this is what is in the db
*/
@Override
public void dbVersionReset() {
//lets get the state from the db so we know what has changed
this.dbVersion = this.clone();
}
/**
*
*/
public boolean equalsDeep(Object obj) {
if (this==obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof GrouperDataRowAssign)) {
return false;
}
GrouperDataRowAssign other = (GrouperDataRowAssign) obj;
return new EqualsBuilder()
//dbVersion DONT EQUALS
.append(this.createdOn, other.createdOn)
.append(this.dataProviderInternalId, other.dataProviderInternalId)
.append(this.dataRowInternalId, other.dataRowInternalId)
.append(this.internalId, other.internalId)
.append(this.memberInternalId, other.memberInternalId)
.isEquals();
}
public void storePrepare() {
if (this.createdOn == null) {
this.createdOn = new Timestamp(System.currentTimeMillis());
}
}
/**
*
*/
@Override
public String toString() {
return GrouperClientUtils.toStringReflection(this, null);
}
}