Skip to content
Snippets Groups Projects
Commit 2e7eabd8 authored by srosse's avatar srosse
Browse files

FXOLAT-358: remove the ChangeManager

parent 4301532c
No related branches found
No related tags found
No related merge requests found
/**
* OLAT - Online Learning and Training<br>
* http://www.olat.org
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS,
* <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Copyright (c) 2005-2006 by JGS goodsolutions GmbH, Switzerland<br>
* http://www.goodsolutions.ch All rights reserved.
* <p>
*/
package org.olat.core.id.change;
import org.olat.core.gui.control.Event;
import org.olat.core.id.OLATResourceable;
import org.olat.core.util.coordinate.CoordinatorManager;
/**
* Description:<br>
*
* <P>
* Initial Date: 21.07.2006 <br>
*
* @author Felix Jost
*/
public class ChangeManager {
//public static final int ACTION_READ = 1;
//public static final int ACTION_APPEND = 2;
public static final int ACTION_CREATE = 4;
public static final int ACTION_UPDATE = 8;
public static final int ACTION_DELETE = 16;
//private static ChangeManager INSTANCE = new ChangeManager();
private ChangeManager() {
// singleton
}
/*public static ChangeManager getInstance() {
return INSTANCE;
}*/
/**
* @see ObjectAccessEvent
* @param action
* @param ores
*/
public static void changed(int action, OLATResourceable ores) {
ObjectAccessEvent cevent = new ObjectAccessEvent(action, ores);
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(cevent, ores);
}
public static boolean isChangeEvent(Event event) {
return event instanceof ObjectAccessEvent; // event.getCommand() == CHANGE_COMMAND;
}
}
/**
* OLAT - Online Learning and Training<br>
* http://www.olat.org
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS,
* <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Copyright (c) 2005-2006 by JGS goodsolutions GmbH, Switzerland<br>
* http://www.goodsolutions.ch All rights reserved.
* <p>
*/
package org.olat.core.id.change;
import org.olat.core.id.OLATResourceable;
import org.olat.core.util.resource.OLATResourceableEvent;
/**
* Description:<br>
* an event which must be fired whenever a business object / olatresourceable
* changed.<br>
* <P>
* Initial Date: 21.07.2006 <br>
*
* @author Felix Jost
*/
public class ObjectAccessEvent extends OLATResourceableEvent {
private static final String CHANGE_COMMAND = new String("o__change_com328898234932");
private final int action;
/**
*
* @param action how it changed or was read (use constants of changemanager class (c,r,u,d,a)
* @param ores the olat resourceable that changed
*/
ObjectAccessEvent(int action, OLATResourceable ores) {
super(CHANGE_COMMAND, ores);
this.action = action;
}
/**
* @return Returns the action. (see constants of ChangeManager class)
*/
public int getAction() {
return action;
}
public String toString() {
String oresS = getDerivedOres();
return "action "+getAction()+", ores "+oresS;
}
}
......@@ -51,7 +51,6 @@ import org.olat.core.gui.control.controller.BasicController;
import org.olat.core.gui.control.generic.modal.DialogBoxController;
import org.olat.core.gui.control.generic.modal.DialogBoxUIFactory;
import org.olat.core.id.Identity;
import org.olat.core.id.change.ChangeManager;
import org.olat.core.logging.AssertException;
import org.olat.core.logging.activity.ActionType;
import org.olat.core.logging.activity.ThreadLocalUserActivityLogger;
......@@ -341,7 +340,6 @@ public class BusinessGroupEditController extends BasicController implements Cont
// values are taken from the modifyBusinessGroupForm
updateBusinessGroup();
// inform index about change
ChangeManager.changed(ChangeManager.ACTION_UPDATE,this.currBusinessGroup);
refreshAllTabs(ureq);
// notify current active users of this business group
BusinessGroupModifiedEvent
......
......@@ -60,7 +60,6 @@ import org.olat.core.gui.control.generic.tool.ToolController;
import org.olat.core.gui.control.generic.tool.ToolFactory;
import org.olat.core.gui.control.state.ControllerState;
import org.olat.core.id.Identity;
import org.olat.core.id.change.ChangeManager;
import org.olat.core.logging.Tracing;
import org.olat.core.logging.activity.ThreadLocalUserActivityLogger;
import org.olat.core.util.Util;
......@@ -282,7 +281,6 @@ public class BGMainController extends MainLayoutBasicController implements Activ
// values are taken from the createBuddyGroupForm
this.currBusinessGroup = createBuddyGroup(ureq);
updateGroupListModelAll();
ChangeManager.changed(ChangeManager.ACTION_CREATE,this.currBusinessGroup);
// after successfully creating a buddygroup 'launch' it
BusinessGroupMainRunController groupRunCtr = BGControllerFactory.getInstance().createRunControllerAsTopNavTab(this.currBusinessGroup,
......@@ -346,7 +344,6 @@ public class BGMainController extends MainLayoutBasicController implements Activ
everybody.add(owners);
everybody.add(participants);
// inform Indexer about change
ChangeManager.changed(ChangeManager.ACTION_DELETE,currBusinessGroup);
// 3) delete the group
currBusinessGroup = bgm.loadBusinessGroup(currBusinessGroup);
......
......@@ -37,7 +37,6 @@ import org.olat.core.gui.control.Event;
import org.olat.core.gui.control.WindowControl;
import org.olat.core.id.Identity;
import org.olat.core.id.OLATResourceable;
import org.olat.core.id.change.ChangeManager;
import org.olat.core.util.event.EventBus;
import org.olat.core.util.event.GenericEventListener;
import org.olat.core.util.resource.OLATResourceableJustBeforeDeletedEvent;
......@@ -135,7 +134,7 @@ public class NoteController extends FormBasicController implements GenericEventL
nm.saveNote(n);
Long newKey = n.getKey();
OLATResourceable ores = OresHelper.createOLATResourceableInstance(Note.class, newKey);
ChangeManager.changed(ChangeManager.ACTION_CREATE, ores);
sec.fireEventToListenersOf(new NoteEvent(getIdentity().getName()), ores);
} else {
nm.updateNote(n);
}
......
......@@ -41,7 +41,6 @@ import org.olat.core.gui.control.generic.modal.DialogBoxController;
import org.olat.core.gui.control.generic.modal.DialogBoxUIFactory;
import org.olat.core.id.Identity;
import org.olat.core.id.OLATResourceable;
import org.olat.core.id.change.ChangeManager;
import org.olat.core.util.event.EventBus;
import org.olat.core.util.event.GenericEventListener;
import org.olat.core.util.resource.OLATResourceableJustBeforeDeletedEvent;
......@@ -166,7 +165,7 @@ public class NoteListController extends BasicController implements GenericEventL
}
public void event(Event event) {
if (ChangeManager.isChangeEvent(event)) {
if (event instanceof NoteEvent) {
populateNLTable();
}
}
......
......@@ -28,23 +28,16 @@ import java.util.List;
import org.apache.lucene.document.Document;
import org.olat.core.commons.persistence.DBFactory;
import org.olat.core.gui.control.Event;
import org.olat.core.id.Identity;
import org.olat.core.id.OLATResourceable;
import org.olat.core.id.Roles;
import org.olat.core.id.change.ChangeManager;
import org.olat.core.id.change.ObjectAccessEvent;
import org.olat.core.id.context.BusinessControl;
import org.olat.core.id.context.ContextEntry;
import org.olat.core.logging.Tracing;
import org.olat.core.util.coordinate.CoordinatorManager;
import org.olat.core.util.event.GenericEventListener;
import org.olat.core.util.resource.OresHelper;
import org.olat.group.BusinessGroup;
import org.olat.group.BusinessGroupManager;
import org.olat.group.BusinessGroupManagerImpl;
import org.olat.search.service.SearchResourceContext;
import org.olat.search.service.SearchServiceImpl;
import org.olat.search.service.document.GroupDocument;
import org.olat.search.service.indexer.AbstractIndexer;
import org.olat.search.service.indexer.OlatFullIndexer;
......@@ -53,7 +46,7 @@ import org.olat.search.service.indexer.OlatFullIndexer;
* Index all business-groups. Includes group-forums and groups-folders.
* @author Christian Guretzki
*/
public class GroupIndexer extends AbstractIndexer implements GenericEventListener {
public class GroupIndexer extends AbstractIndexer {
private BusinessGroupManager businessGroupManager;
......@@ -138,25 +131,4 @@ public class GroupIndexer extends AbstractIndexer implements GenericEventListene
public String getSupportedTypeName() {
return OresHelper.calculateTypeName(BusinessGroup.class);
}
// Handling Update Event
public void event(Event event) {
if (ChangeManager.isChangeEvent(event)) {
ObjectAccessEvent oae = (ObjectAccessEvent) event;
if (Tracing.isDebugEnabled(GroupIndexer.class)) Tracing.logDebug("info: oae = "+oae.toString(),GroupIndexer.class);
int action = oae.getAction();
Long id = oae.getOresId();
BusinessGroup newBusinessGroup = BusinessGroupManagerImpl.getInstance().loadBusinessGroup(id,true);
SearchResourceContext searchResourceContext = new SearchResourceContext(); // businessContextString
searchResourceContext.setBusinessControlFor(newBusinessGroup);
Document document = GroupDocument.createDocument(searchResourceContext, newBusinessGroup);
if (action == ChangeManager.ACTION_UPDATE) {
//-> OLAT-3367 SearchServiceImpl.getInstance().addToIndex(document);
} else if (action == ChangeManager.ACTION_CREATE) {
//-> OLAT-3367 SearchServiceImpl.getInstance().addToIndex(document);
} else if (action == ChangeManager.ACTION_DELETE) {
//-> OLAT-3367 SearchServiceImpl.getInstance().deleteFromIndex(document);
}
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment