private Class<T> type;
+ /**
+ * @deprecated use factory method instead (TODO: to be made protected once no longer used publicly)
+ */
+ @Deprecated
public TypedEntityReference(Class<T> type, UUID uuid, String label) {
super(uuid, label);
this.type = type;
}
+ /**
+ * @deprecated use factory method instead (TODO; to be made protected once no longer used publicly)
+ */
+ @Deprecated
public TypedEntityReference(Class<T> type, UUID uuid) {
super(uuid, null);
this.type = type;
}
- public static <T extends CdmBase> TypedEntityReference<T> fromEntity(T entity) {
+ public static <T extends CdmBase> TypedEntityReference<T> fromEntity(T entity, boolean withLabel) {
if(entity == null) {
return null;
}
entity = HibernateProxyHelper.deproxy(entity);
- if(IdentifiableEntity.class.isAssignableFrom(entity.getClass())) {
+ if(withLabel && IdentifiableEntity.class.isAssignableFrom(entity.getClass())) {
return new TypedEntityReference<T>((Class<T>)entity.getClass(), entity.getUuid(), ((IdentifiableEntity)entity).getTitleCache());
} else {
return new TypedEntityReference<T>((Class<T>)entity.getClass(), entity.getUuid());
}
}
+ public static <T extends CdmBase> TypedEntityReference<T> fromEntity(T entity) {
+ return TypedEntityReference.fromEntity(entity, true);
+ }
+
public Class<T> getType() {
return type;
}
TaggedTextBuilder finalBuilder = new TaggedTextBuilder();
if(withNameIfAvailable && manager.getTypifiedNameCache() != null){
- finalBuilder.add(TagEnum.name, manager.getTypifiedNameCache(), TypedEntityReference.fromEntity(manager.getTypifiedName()));
+ finalBuilder.add(TagEnum.name, manager.getTypifiedNameCache(), TypedEntityReference.fromEntity(manager.getTypifiedName(), false));
finalBuilder.addPostSeparator(POST_NAME_SEPARTOR);
}
workingsetBuilder.add(TagEnum.separator, TYPE_DESIGNATION_SEPARATOR);
}
- workingsetBuilder.add(TagEnum.typeDesignation, stringify(typeDes), TypedEntityReference.fromEntity(typeDes));
+ workingsetBuilder.add(TagEnum.typeDesignation, stringify(typeDes), TypedEntityReference.fromEntity(typeDes, false));
// workingsetBuilder.add(TagEnum.typeDesignation, typeDesignationEntityReference.getLabel(), typeDesignationEntityReference);
if (withCitation){
if (ref != null){
DefaultReferenceCacheStrategy strategy = ((DefaultReferenceCacheStrategy)ref.getCacheStrategy());
String shortCitation = strategy.createShortCitation(ref, source.getCitationMicroReference(), false);
- workingsetBuilder.add(TagEnum.reference, shortCitation, TypedEntityReference.fromEntity(ref));
+ workingsetBuilder.add(TagEnum.reference, shortCitation, TypedEntityReference.fromEntity(ref, false));
}
}