-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix errors when Orienteer was reload #2
Open
vitalii-honchar
wants to merge
4
commits into
OrienteerBAP:master
Choose a base branch
from
vitalii-honchar:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
6896448
Change public access to private access
vitalii-honchar 7154927
Create OTelegramCustomAttributes - class with custom attributes for O…
vitalii-honchar 3229c8b
Rename method "get" to "getOrCreate"
vitalii-honchar af3a3d7
Delete OTelegramCustomAttribute and use method getOrCreate() of class…
vitalii-honchar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ | |
import org.orienteer.core.component.structuretable.OrienteerStructureTable; | ||
import org.orienteer.core.widget.AbstractModeAwareWidget; | ||
import org.orienteer.core.widget.Widget; | ||
import org.orienteer.telegram.module.OTelegramModule; | ||
import org.orienteer.telegram.module.OTelegramCustomAttributes; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import ru.ydn.wicket.wicketorientdb.components.TransactionlessForm; | ||
|
@@ -49,10 +49,10 @@ public class OTelegramBotWidget extends AbstractModeAwareWidget<OClass> { | |
public OTelegramBotWidget(String id, IModel<OClass> model, IModel<ODocument> widgetDocumentModel) { | ||
super(id, model, widgetDocumentModel); | ||
Form<OClass> form = new TransactionlessForm<OClass>("form"); | ||
propertiesList.add(OTelegramModule.TELEGRAM_SEARCH.getName()); | ||
propertiesList.add(OTelegramModule.TELEGRAM_DOCUMENTS_LIST.getName()); | ||
propertiesList.add(OTelegramModule.TELEGRAM_CLASS_DESCRIPTION.getName()); | ||
propertiesList.add(OTelegramModule.TELEGRAM_SEARCH_QUERY.getName()); | ||
propertiesList.add(OTelegramCustomAttributes.TELEGRAM_SEARCH.getOrCreate().getName()); | ||
propertiesList.add(OTelegramCustomAttributes.TELEGRAM_DOCUMENTS_LIST.getOrCreate().getName()); | ||
propertiesList.add(OTelegramCustomAttributes.TELEGRAM_CLASS_DESCRIPTION.getOrCreate().getName()); | ||
propertiesList.add(OTelegramCustomAttributes.TELEGRAM_SEARCH_QUERY.getOrCreate().getName()); | ||
structureTable = new OrienteerStructureTable<OClass, String>("attributes", model, propertiesList) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Theoretically you can use CustomAttribute instead of String here. |
||
|
||
@Override | ||
|
@@ -71,13 +71,13 @@ protected Component resolveComponent(String id, DisplayMode mode, String critery | |
mode = DisplayMode.VIEW; | ||
} | ||
if (DisplayMode.VIEW.equals(mode)) { | ||
if (critery.equals(OTelegramModule.TELEGRAM_SEARCH_QUERY.getName())) { | ||
if (critery.equals(OTelegramCustomAttributes.TELEGRAM_SEARCH_QUERY.getOrCreate().getName())) { | ||
return new Label(id, getModel()); | ||
} else { | ||
return new BooleanViewPanel(id, Model.<Boolean>of(getModel())); | ||
} | ||
} else if (DisplayMode.EDIT.equals(mode)){ | ||
if (critery.equals(OTelegramModule.TELEGRAM_SEARCH_QUERY.getName())) { | ||
if (critery.equals(OTelegramCustomAttributes.TELEGRAM_SEARCH_QUERY.getOrCreate().getName())) { | ||
return new TextField(id, getModel()); | ||
} else return new BooleanEditPanel(id, Model.<Boolean>of(getModel())); | ||
} | ||
|
33 changes: 33 additions & 0 deletions
33
src/main/java/org/orienteer/telegram/module/OTelegramCustomAttributes.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,33 @@ | ||
package org.orienteer.telegram.module; | ||
|
||
import com.orientechnologies.orient.core.metadata.schema.OType; | ||
import org.orienteer.core.CustomAttribute; | ||
|
||
/** | ||
* @author Vitaliy Gonchar | ||
*/ | ||
public enum OTelegramCustomAttributes { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Commented below. It seems to be quite dummy file. |
||
TELEGRAM_SEARCH("orienteer.telegramSearch", OType.BOOLEAN, false, false, false), | ||
TELEGRAM_DOCUMENTS_LIST("orienteer.telegramDocumentsList", OType.BOOLEAN, false, false, false), | ||
TELEGRAM_SEARCH_QUERY("orienteer.telegramSearchQuery", OType.STRING, null, true, false), | ||
TELEGRAM_CLASS_DESCRIPTION("orienteer.telegramClassDescription", OType.BOOLEAN, false, false, false); | ||
|
||
private final String name; | ||
private final OType type; | ||
private final Object defaultValue; | ||
private final boolean encode; | ||
private final boolean hiearchical; | ||
|
||
OTelegramCustomAttributes(String name, OType type, Object defaultValue, boolean encode, boolean hiearchical) { | ||
this.name = name; | ||
this.type = type; | ||
this.defaultValue = defaultValue; | ||
this.encode = encode; | ||
this.hiearchical = hiearchical; | ||
} | ||
|
||
public CustomAttribute getOrCreate() { | ||
CustomAttribute result = CustomAttribute.getIfExists(name); | ||
return result != null ? result : CustomAttribute.create(name, type, defaultValue, encode, hiearchical); | ||
} | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we discussed that I thought that you will use CustomAttributes and add "getOrCreate()" method there instead of creating separate class OTelegramCustomAttributes. Any problems with dynamic loading in that case? If no - lets get rid of OTelegramCustomAttributes.