preferences.txt
/*
* ModelStoreTypeConfigurable.java
*
* Created on October 3, 2006, 11:02 AM
*/

package com.acme.datamgmt.biz;

import java.util.*;

import com.osm.biz.*;
import com.osm.datamgmt.integration.*;
import com.osm.datamgmt.biz.*;
import com.osm.exception.*;

public class ModelStoreTypeConfigurable extends ModelStoreType {

private boolean majorVersionType () {
boolean b = true;
try {
b = UserProfile.getUserProfile().getBooleanProperty("acme_major", true);
} catch (Throwable T) {
b = true;
}
return b;
}

private boolean allowMinorVersions () {
boolean b = true;
try {
b = UserProfile.getUserProfile().getBooleanProperty("acme_allowminor", true);
} catch (Throwable T) {
b = true;
}
return b;
}

/** Constructors */
public ModelStoreTypeConfigurable(Object storeType, WMAttribute att,
WMObject wmObject) throws WMException {
super(storeType, att, wmObject);
}
public ModelStoreTypeConfigurable(WMAttribute att, WMObject wmObject)
throws WMException {
super(att, wmObject);
}

/* Override VersionbleStoreType.getNewVersionStoreTypes.
* Controls the contents of the "Save Type" menu for the individual
* items in the Save dialog. It does not control the "Save Type" menu
* in the upper left hand corner of the Save dialog
*/

public List getNewVersionStoreTypes() throws WMException {
List newVersionStoreTypes = new ArrayList();
if (majorVersionType()) {
newVersionStoreTypes.add(STORE_TYPE_NEW_REVISION);
if (allowMinorVersions()) {
newVersionStoreTypes.add(STORE_TYPE_NEW_INCREMENT);
}
}
else {
if (allowMinorVersions()) {
newVersionStoreTypes.add(STORE_TYPE_NEW_INCREMENT);
}
newVersionStoreTypes.add(STORE_TYPE_NEW_REVISION);
}
return newVersionStoreTypes;
}

/* Override StoreType.getStoreTypesForMenu.
* Controls the "Save Type" menu in the upper left corner of
* the Save dialog
*/

public List getStoreTypesForMenu() {

/* call the original method */
List list = super.getStoreTypesForMenu();

/* if minor versions aren't allowed, remove them from the menu list */
if (!allowMinorVersions()) {
if (list.contains(STORE_TYPE_INCREMENT_MODIFIED)) {
list.remove(STORE_TYPE_INCREMENT_MODIFIED);
}
}

return list;
}

/* Overrides VersionableStoreType.addNoneStoreType.
* Default is that only "none" and "Major Version" are listed.
* If minor versions are allowed, add minor version store type.
*/

protected void addNoneStoreType(List list) throws WMException {
/* call the original method */
super.addNoneStoreType(list);
if (allowMinorVersions()) {
list.add(STORE_TYPE_NEW_INCREMENT);
}
}
}
Was this helpful?