Restrictions.eq("name", tprop.getName()));
if (type == null) {
type = new DocumentType(tprop);
+ type.getDefaultUses().add(type); //RKV
getDocumentTypeDAO().create(type);
} else {
LOG.info(MessageKeyEnum.DCT_000001.toString(), tprop.getName());
slist.toArray(new ProjectSettingsService.Step[slist
.size()]));
if (uses != null) {
- tdoc = maptype.get(uses);
- if (tdoc == null) {
- LOG.warn("Undefined \"" + uses
- + "\" document type.");
- } else {
- tprop.setUses(tdoc);
+ // Parse uses attribute
+ String[] usesArr = uses.split(",");
+ List<DocumentType> usesTypesList = new ArrayList<DocumentType>();
+ for (String usesType: usesArr) {
+ tdoc = maptype.get(usesType.trim());
+ if (tdoc == null) {
+ LOG.warn("Undefined \"" + usesType.trim()
+ + "\" document type.");
+ } else {
+ if (!usesTypesList.contains(tdoc)) {
+ usesTypesList.add(tdoc);
+ }
+ }
}
+ tprop.setUses(usesTypesList.toArray(new DocumentType[]{}));
}
if (step != null) {
tprop.setResult(step);
step = getProjectElementService().getSteps(_mystudy);
for (int i = step.length - 1; i > -1; i--) {
Step firstep = step[i];
- if (firstep.getNumber() > base) {
- continue;
+ if (firstep.getNumber() <= base) {
+ _involving.add(0, firstep);
}
- _involving.add(0, firstep);
}
}
for (Iterator<DocumentType> i = uses.iterator(); i.hasNext();) {
DocumentType usetype = i.next();
List<Document> usedoc = mystudy.collectInvolvedDocuments(usetype);
- if (usedoc.isEmpty()) {
+ if (usedoc.isEmpty() && (!usetype.equals(type))) {
setupDefaultUses(usetype);
} else {
defuses.addAll(usedoc);