CdmPreference preference = null;
if (preferredCode == null){
preference = controller.getPreferenceService().find(key);
- int index = StringUtils.lastIndexOf(preference.getValue(), ".");
- UUID uuid = UUID.fromString(preference.getValue().substring(index +1, preference.getValue().length()));
- preferredCode = NomenclaturalCode.getByUuid(uuid);
+ if (preference == null){
+ return;
+ } else{
+ int index = StringUtils.lastIndexOf(preference.getValue(), ".");
+ UUID uuid = UUID.fromString(preference.getValue().substring(index +1, preference.getValue().length()));
+ preferredCode = NomenclaturalCode.getByUuid(uuid);
+ }
} else{
preference = CdmPreference.NewInstance(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NomenclaturalCode, preferredCode.getKey());
controller.getPreferenceService().set(preference);