javax.persistence.EnumType Java Examples

The following examples show how to use javax.persistence.EnumType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CheckCore.java    From o2oa with GNU Affero General Public License v3.0 6 votes vote down vote up
public static void checkEnum(List<Class<?>> classes) throws Exception {
	for (Class<?> cls : classes) {
		List<Field> fields = FieldUtils.getFieldsListWithAnnotation(cls, FieldDescribe.class);
		for (Field field : fields) {
			if (field.getType().isEnum()) {
				Enumerated enumerated = field.getAnnotation(Enumerated.class);
				Column column = field.getAnnotation(Column.class);
				if (null == enumerated || (!Objects.equals(EnumType.STRING, enumerated.value())) || (null == column)
						|| column.length() > 200) {
					System.err.println(String.format("checkEnum error: class: %s, field: %s.", cls.getName(),
							field.getName()));
				}
			}
		}
	}
}
 
Example #2
Source File: TeamEventAttendeeDO.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @return the status
 */
@Enumerated(EnumType.STRING)
@Column(length = 100)
public TeamAttendeeStatus getStatus()
{
  return status;
}
 
Example #3
Source File: JPAOverriddenAnnotationReader.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Adds a @MapKeyEnumerated annotation to the specified annotationList if the specified element
 * contains a map-key-enumerated sub-element. This should only be the case for
 * element-collection, many-to-many, or one-to-many associations.
 */
private void getMapKeyEnumerated(List<Annotation> annotationList, Element element) {
	Element subelement = element != null ? element.element( "map-key-enumerated" ) : null;
	if ( subelement != null ) {
		AnnotationDescriptor ad = new AnnotationDescriptor( MapKeyEnumerated.class );
		EnumType value = EnumType.valueOf( subelement.getTextTrim() );
		ad.setValue( "value", value );
		annotationList.add( AnnotationFactory.create( ad ) );
	}
}
 
Example #4
Source File: TeamEventDO.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Gets type of event action. AUDIO or DISPLAY
 * 
 * @return the reminderType
 */
@Enumerated(EnumType.STRING)
@Column(name = "reminder_action_type")
public ReminderActionType getReminderActionType()
{
  return reminderActionType;
}
 
Example #5
Source File: TaskDO.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
/** -&gt; Gantt */
@Deprecated
@Enumerated(EnumType.STRING)
@Column(name = "gantt_rel_type", length = 15)
public GanttRelationType getGanttRelationType()
{
  return ganttRelationType;
}
 
Example #6
Source File: PersonData.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
* Gets the gender.
*
* @return the gender
*/
  @Basic
  @Column(name = "GENDER")
  @Enumerated(EnumType.STRING)
  public SexType getGender() {
      return gender;
  }
 
Example #7
Source File: DocumentPersonReferenceData.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
* Gets the role description.
*
* @return the role description
*/
  @Basic
  @Column(name = "ROLE_DESCRIPTION")
  @Enumerated(EnumType.STRING)
  public DocumentPersonReferenceRoleType getRoleDescription() {
      return roleDescription;
  }
 
Example #8
Source File: LendingType.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
* Gets the value.
*
* @return the value
*/
  @Basic
  @Column(name = "VALUE_")
  @Enumerated(EnumType.STRING)
  public LendingTypeCategory getValue() {
      return value;
  }
 
Example #9
Source File: Region.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
* Gets the value.
*
* @return the value
*/
  @Basic
  @Column(name = "VALUE_")
  @Enumerated(EnumType.STRING)
  public RegionCategory getValue() {
      return value;
  }
 
Example #10
Source File: TaskDO.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
@Enumerated(EnumType.STRING)
@Column(name = "timesheet_booking_status", length = 20, nullable = false)
public TimesheetBookingStatus getTimesheetBookingStatus()
{
  if (timesheetBookingStatus == null) {
    return TimesheetBookingStatus.DEFAULT;
  } else {
    return timesheetBookingStatus;
  }
}
 
Example #11
Source File: VoteDataEmbeddedId.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
* Gets the concern.
*
* @return the concern
*/
  @Basic
  @Column(name = "CONCERN")
  @Enumerated(EnumType.STRING)
  public VoteIssueType getConcern() {
      return concern;
  }
 
Example #12
Source File: VoteData.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
* Gets the vote.
*
* @return the vote
*/
  @Basic
  @Column(name = "VOTE")
  @Enumerated(EnumType.STRING)
  public VoteDecision getVote() {
      return vote;
  }
 
Example #13
Source File: VoteDataDto.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
* Gets the ballot type.
*
* @return the ballot type
*/
  @Basic
  @Column(name = "BALLOT_TYPE")
  @Enumerated(EnumType.STRING)
  public BallotType getBallotType() {
      return ballotType;
  }
 
Example #14
Source File: VoteDataDto.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
* Gets the vote.
*
* @return the vote
*/
  @Basic
  @Column(name = "VOTE")
  @Enumerated(EnumType.STRING)
  public VoteDecision getVote() {
      return vote;
  }
 
Example #15
Source File: AssignmentElement.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
* Gets the org code.
*
* @return the org code
*/
  @Basic
  @Column(name = "ORG_CODE")
  @Enumerated(EnumType.STRING)
  public OrgCode getOrgCode() {
      return orgCode;
  }
 
Example #16
Source File: User.java    From website with GNU Affero General Public License v3.0 5 votes vote down vote up
@ElementCollection(targetClass = Role.class, fetch = FetchType.EAGER)
@CollectionTable(name = "USER_ROLES", joinColumns = @JoinColumn(name = "USER_ID"))
@Enumerated(EnumType.STRING)
@Column(name = "role", nullable = false)
public Set<Role> getRoles() {
	return roles;
}
 
Example #17
Source File: KontoDO.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @return the status
 */
@Enumerated(EnumType.STRING)
@Column(length = 10)
public KontoStatus getStatus()
{
  return status;
}
 
Example #18
Source File: ToDoDO.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
@Enumerated(EnumType.STRING)
@Column(length = 20)
public ToDoStatus getStatus()
{
  return status;
}
 
Example #19
Source File: User.java    From website with GNU Affero General Public License v3.0 4 votes vote down vote up
@Enumerated(EnumType.STRING)
public UserType getType() {
	return type;
}
 
Example #20
Source File: ImportItem.java    From website with GNU Affero General Public License v3.0 4 votes vote down vote up
@Enumerated(EnumType.STRING)
@Column(nullable = false)
public Status getStatus() {
    return status;
}
 
Example #21
Source File: TaskDO.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
@Enumerated(EnumType.STRING)
@Column(length = PRIORITY_LENGTH)
public Priority getPriority()
{
  return priority;
}
 
Example #22
Source File: RuleViolation.java    From cia with Apache License 2.0 4 votes vote down vote up
/**
 * Gets the status.
 *
 * @return the status
 */
@Enumerated(EnumType.STRING)
   @Column(name = "status")
public Status getStatus() {
	return status;
}
 
Example #23
Source File: ImportJob.java    From website with GNU Affero General Public License v3.0 4 votes vote down vote up
@Enumerated(EnumType.STRING)
public Health getHealth() {
    return health;
}
 
Example #24
Source File: JavaxPersistenceImpl.java    From ormlite-core with ISC License 4 votes vote down vote up
@Override
public DatabaseFieldConfig createFieldConfig(DatabaseType databaseType, Field field) {
	Column columnAnnotation = field.getAnnotation(Column.class);
	Basic basicAnnotation = field.getAnnotation(Basic.class);
	Id idAnnotation = field.getAnnotation(Id.class);
	GeneratedValue generatedValueAnnotation = field.getAnnotation(GeneratedValue.class);
	OneToOne oneToOneAnnotation = field.getAnnotation(OneToOne.class);
	ManyToOne manyToOneAnnotation = field.getAnnotation(ManyToOne.class);
	JoinColumn joinColumnAnnotation = field.getAnnotation(JoinColumn.class);
	Enumerated enumeratedAnnotation = field.getAnnotation(Enumerated.class);
	Version versionAnnotation = field.getAnnotation(Version.class);

	if (columnAnnotation == null && basicAnnotation == null && idAnnotation == null && oneToOneAnnotation == null
			&& manyToOneAnnotation == null && enumeratedAnnotation == null && versionAnnotation == null) {
		return null;
	}

	DatabaseFieldConfig config = new DatabaseFieldConfig();
	String fieldName = field.getName();
	if (databaseType.isEntityNamesMustBeUpCase()) {
		fieldName = databaseType.upCaseEntityName(fieldName);
	}
	config.setFieldName(fieldName);

	if (columnAnnotation != null) {
		if (stringNotEmpty(columnAnnotation.name())) {
			config.setColumnName(columnAnnotation.name());
		}
		if (stringNotEmpty(columnAnnotation.columnDefinition())) {
			config.setColumnDefinition(columnAnnotation.columnDefinition());
		}
		config.setWidth(columnAnnotation.length());
		config.setCanBeNull(columnAnnotation.nullable());
		config.setUnique(columnAnnotation.unique());
	}
	if (basicAnnotation != null) {
		config.setCanBeNull(basicAnnotation.optional());
	}
	if (idAnnotation != null) {
		if (generatedValueAnnotation == null) {
			config.setId(true);
		} else {
			// generatedValue only works if it is also an id according to {@link GeneratedValue)
			config.setGeneratedId(true);
		}
	}
	if (oneToOneAnnotation != null || manyToOneAnnotation != null) {
		// if we have a collection then make it a foreign collection
		if (Collection.class.isAssignableFrom(field.getType())
				|| ForeignCollection.class.isAssignableFrom(field.getType())) {
			config.setForeignCollection(true);
			if (joinColumnAnnotation != null && stringNotEmpty(joinColumnAnnotation.name())) {
				config.setForeignCollectionColumnName(joinColumnAnnotation.name());
			}
			if (manyToOneAnnotation != null) {
				FetchType fetchType = manyToOneAnnotation.fetch();
				if (fetchType != null && fetchType == FetchType.EAGER) {
					config.setForeignCollectionEager(true);
				}
			}
		} else {
			// otherwise it is a foreign field
			config.setForeign(true);
			if (joinColumnAnnotation != null) {
				if (stringNotEmpty(joinColumnAnnotation.name())) {
					config.setColumnName(joinColumnAnnotation.name());
				}
				config.setCanBeNull(joinColumnAnnotation.nullable());
				config.setUnique(joinColumnAnnotation.unique());
			}
		}
	}
	if (enumeratedAnnotation != null) {
		EnumType enumType = enumeratedAnnotation.value();
		if (enumType != null && enumType == EnumType.STRING) {
			config.setDataType(DataType.ENUM_STRING);
		} else {
			config.setDataType(DataType.ENUM_INTEGER);
		}
	}
	if (versionAnnotation != null) {
		// just the presence of the version...
		config.setVersion(true);
	}
	if (config.getDataPersister() == null) {
		config.setDataPersister(DataPersisterManager.lookupForField(field));
	}
	config.setUseGetSet(DatabaseFieldConfig.findGetMethod(field, databaseType, false) != null
			&& DatabaseFieldConfig.findSetMethod(field, databaseType, false) != null);
	return config;
}
 
Example #25
Source File: AuthenticationLog.java    From website with GNU Affero General Public License v3.0 4 votes vote down vote up
@Column(nullable = false)
@Enumerated(EnumType.STRING)
public AuthenticationLogContext getContext() {
	return context;
}
 
Example #26
Source File: AuftragsPositionDO.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
@Enumerated(EnumType.STRING)
@Column(name = "mode_of_payment_type", length = 13)
public ModeOfPaymentType getModeOfPaymentType()
{
  return modeOfPaymentType;
}
 
Example #27
Source File: Licence.java    From website with GNU Affero General Public License v3.0 4 votes vote down vote up
@Column(nullable = false)
@Enumerated(EnumType.STRING)
public LicenceStatus getStatus() {
	return status;
}
 
Example #28
Source File: Licence.java    From website with GNU Affero General Public License v3.0 4 votes vote down vote up
@Enumerated(EnumType.STRING)
public InvoiceState getInvoiceState() {
	return invoiceState;
}
 
Example #29
Source File: PostausgangDO.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
@Enumerated(EnumType.STRING)
@Column(name = "post_type", length = 100, nullable = false)
public PostType getType()
{
  return type;
}
 
Example #30
Source File: PublisherPaymentRequest.java    From website with GNU Affero General Public License v3.0 4 votes vote down vote up
@Column(nullable = false)
@Enumerated(EnumType.STRING)
public PublisherPaymentRequestStatus getStatus() {
	return status;
}