This repository has been archived by the owner on Feb 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
96f6370
commit 733b5c9
Showing
18 changed files
with
752 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
app/src/main/java/org/incode/module/document/app/services/fakesched/FakeScheduler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package org.incode.module.document.app.services.fakesched; | ||
|
||
import java.util.List; | ||
|
||
import javax.inject.Inject; | ||
|
||
import org.apache.isis.applib.annotation.Action; | ||
import org.apache.isis.applib.annotation.DomainService; | ||
import org.apache.isis.applib.annotation.DomainServiceLayout; | ||
import org.apache.isis.applib.annotation.NatureOfService; | ||
import org.apache.isis.applib.annotation.ParameterLayout; | ||
import org.apache.isis.applib.annotation.SemanticsOf; | ||
import org.apache.isis.applib.services.xactn.TransactionService; | ||
import org.apache.isis.core.runtime.authentication.standard.SimpleSession; | ||
|
||
import org.isisaddons.module.command.dom.BackgroundCommandExecutionFromBackgroundCommandServiceJdo; | ||
import org.isisaddons.module.command.dom.BackgroundCommandServiceJdoRepository; | ||
import org.isisaddons.module.command.dom.CommandJdo; | ||
|
||
@DomainService( | ||
nature = NatureOfService.VIEW_MENU_ONLY, | ||
objectType = "incodeCommunicationsDemo.FakeScheduler" | ||
) | ||
@DomainServiceLayout( | ||
named = "Fakes", | ||
menuBar = DomainServiceLayout.MenuBar.SECONDARY, | ||
menuOrder = "110" | ||
) | ||
public class FakeScheduler { | ||
|
||
@Action(semantics = SemanticsOf.NON_IDEMPOTENT) | ||
public void runBackgroundCommands( | ||
@ParameterLayout(named = "Wait for (ms)") | ||
final Integer waitFor) throws InterruptedException { | ||
|
||
List<CommandJdo> commands = backgroundCommandRepository.findBackgroundCommandsNotYetStarted(); | ||
if(commands.isEmpty()) { | ||
throw new IllegalStateException("There are no commands not yet started"); | ||
} | ||
|
||
transactionService.nextTransaction(); | ||
|
||
BackgroundCommandExecutionFromBackgroundCommandServiceJdo backgroundExec = | ||
new BackgroundCommandExecutionFromBackgroundCommandServiceJdo(); | ||
final SimpleSession session = new SimpleSession("scheduler_user", new String[] { "admin_role" }); | ||
|
||
final Thread thread = new Thread(() -> backgroundExec.execute(session, null)); | ||
thread.start(); | ||
|
||
thread.join(waitFor); | ||
|
||
commands = backgroundCommandRepository.findBackgroundCommandsNotYetStarted(); | ||
if(!commands.isEmpty()) { | ||
throw new IllegalStateException("There are still " + commands.size() + " not yet started"); | ||
} | ||
} | ||
|
||
// using a validateXxx rather than a hideXxx because of https://issues.apache.org/jira/browse/ISIS-1593 | ||
public String validateRunBackgroundCommands(final Integer waitFor) { | ||
List<CommandJdo> commands = backgroundCommandRepository.findBackgroundCommandsNotYetStarted(); | ||
return commands.isEmpty() ? "No background commands to run" : null; | ||
} | ||
|
||
public Integer default0RunBackgroundCommands() { | ||
return 5000; | ||
} | ||
|
||
@Inject | ||
protected BackgroundCommandServiceJdoRepository backgroundCommandRepository; | ||
|
||
@Inject | ||
protected TransactionService transactionService; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...java/org/incode/module/document/dom/impl/applicability/AttachmentAdvisorAttachToNone.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright 2016 Dan Haywood | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.incode.module.document.dom.impl.applicability; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import org.incode.module.document.dom.impl.docs.DocumentTemplate; | ||
|
||
/** | ||
* To allow documents to be rendered that are by default attached to no other objects. | ||
*/ | ||
public class AttachmentAdvisorAttachToNone extends AttachmentAdvisorAbstract<Object> { | ||
|
||
public AttachmentAdvisorAttachToNone() { | ||
super(Object.class); | ||
} | ||
|
||
@Override | ||
protected List<PaperclipSpec> doAdvise( | ||
final DocumentTemplate documentTemplate, | ||
final Object domainObject) { | ||
return Collections.emptyList(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.