diff options
| author | Jonathan Bauer | 2015-08-21 15:27:38 +0200 |
|---|---|---|
| committer | Jonathan Bauer | 2015-08-21 15:27:38 +0200 |
| commit | a24d803080a574240220d16e8fc52256cd156b98 (patch) | |
| tree | b4503eca59a235893e7dc2c7abb7f8a8810502c0 | |
| parent | [client] ThriftAction in ImageCustomPermissionWindow (diff) | |
| download | tutor-module-a24d803080a574240220d16e8fc52256cd156b98.tar.gz tutor-module-a24d803080a574240220d16e8fc52256cd156b98.tar.xz tutor-module-a24d803080a574240220d16e8fc52256cd156b98.zip | |
[client] ThriftActions for lecture creation
and minor comments
4 files changed, 55 insertions, 7 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureListWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureListWindow.java index 6d80aecb..32ad4443 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureListWindow.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureListWindow.java @@ -27,6 +27,7 @@ import org.openslx.dozmod.gui.helper.MessageType; import org.openslx.dozmod.gui.window.layout.LectureListWindowLayout; import org.openslx.dozmod.thrift.Session; import org.openslx.dozmod.thrift.cache.LectureCache; +import org.openslx.thrifthelper.ThriftManager; import org.openslx.util.QuickTimer; import org.openslx.util.QuickTimer.Task; @@ -46,12 +47,10 @@ public class LectureListWindow extends LectureListWindowLayout { public void removeUpdate(DocumentEvent e) { changedUpdate(e); } - @Override public void insertUpdate(DocumentEvent e) { changedUpdate(e); } - @Override public void changedUpdate(DocumentEvent e) { // stuff @@ -106,7 +105,7 @@ public class LectureListWindow extends LectureListWindowLayout { deleteButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - // TODO Auto-generated method stub +// ThriftManager.getSatClient().deleteLecture(userToken, lectureId); } }); diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageWizard.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageWizard.java index b2c2604d..12950a1f 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageWizard.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageWizard.java @@ -60,7 +60,7 @@ public class ImageWizard extends Wizard implements UiFeedback { @Override public void performFinish() { - // TODO run the actually request over external threaded class? + // TODO check status of each step and stop if something goes wrong // push image base to satellite ThriftActions.updateImageBase(JOptionPane.getFrameForComponent(this), uploadWizardState.uuid, imageBaseWriteFromState()); diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/LectureCreationPage.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/LectureCreationPage.java index 373e0931..7a655c24 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/LectureCreationPage.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/LectureCreationPage.java @@ -37,12 +37,10 @@ public class LectureCreationPage extends LectureCreationPageLayout { public void removeUpdate(DocumentEvent e) { changedUpdate(e); } - @Override public void insertUpdate(DocumentEvent e) { changedUpdate(e); } - @Override public void changedUpdate(DocumentEvent e) { reactToUserInput(); diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java index e6e39a58..5b2a931b 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java @@ -17,6 +17,8 @@ import org.openslx.bwlp.thrift.iface.ImageBaseWrite; import org.openslx.bwlp.thrift.iface.ImageDetailsRead; import org.openslx.bwlp.thrift.iface.ImagePermissions; import org.openslx.bwlp.thrift.iface.ImageVersionWrite; +import org.openslx.bwlp.thrift.iface.LecturePermissions; +import org.openslx.bwlp.thrift.iface.LectureWrite; import org.openslx.bwlp.thrift.iface.TAuthorizationException; import org.openslx.bwlp.thrift.iface.TImageDataException; import org.openslx.bwlp.thrift.iface.TransferInformation; @@ -29,6 +31,7 @@ import org.openslx.dozmod.gui.Gui.GuiCallable; import org.openslx.dozmod.gui.MainWindow; import org.openslx.dozmod.gui.helper.MessageType; import org.openslx.dozmod.gui.helper.QFileChooser; +import org.openslx.dozmod.gui.wizard.LectureWizard; import org.openslx.dozmod.thrift.cache.MetaDataCache; import org.openslx.thrifthelper.ThriftManager; import org.openslx.util.QuickTimer; @@ -487,7 +490,53 @@ public class ThriftActions { } }); } - + + /* ******************************************************************************* + * + * LECTURE CREATION + * + * Methods to create lectures + * + ********************************************************************************/ + /** + * Creates a lecture with the given meta data + * + * @param frame to show user feedback on + * @param meta actual meta data as LectureWrite + * @return the created lecture's id if it worked, null otherwise + */ + public static String createLecture(final Frame frame, final LectureWrite meta) { + if (meta == null) + return null; + String uuid = null; + try { + // push to sat + uuid = ThriftManager.getSatClient().createLecture(Session.getSatelliteToken(), meta); + } catch (TException e) { + ThriftError.showMessage(frame, LOGGER, e, "Failed to create lecture"); + } + return uuid; + } + /** + * Writes custom lecture permissions (permissions param) for the given lectureId. + * + * @param frame to show user feedback on + * @param lectureId lecture's id to write custom permissions for + * @param permissions actual permission map to push + */ + public static void writeLecturePermissions(final Frame frame, final String lectureId, final Map<String, LecturePermissions> permissions) { + try { + ThriftManager.getSatClient().writeLecturePermissions(Session.getSatelliteToken(), lectureId, permissions); + } catch (TException e) { + ThriftError.showMessage(frame, LOGGER, e, "Failed to write lecture permissions"); + } + } + + /* ******************************************************************************* + * + * PRIVATE HELPERS + * + ********************************************************************************/ /** * Helper to ask the user for confirmation. Returns his choice. * @@ -498,4 +547,6 @@ public class ThriftActions { private static boolean userConfirmed(final Frame frame, final String message) { return Gui.showMessageBox(frame, message, MessageType.QUESTION_YESNO, LOGGER, null); } + + } |
