This repository has been archived by the owner on Dec 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 46
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
Showing
17 changed files
with
401 additions
and
47 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
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
26 changes: 26 additions & 0 deletions
26
src/main/java/org/xbib/elasticsearch/action/langdetect/profile/LangdetectProfileAction.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,26 @@ | ||
package org.xbib.elasticsearch.action.langdetect.profile; | ||
|
||
import org.elasticsearch.action.admin.indices.IndicesAction; | ||
import org.elasticsearch.client.IndicesAdminClient; | ||
|
||
public class LangdetectProfileAction extends IndicesAction<LangdetectProfileRequest, LangdetectProfileResponse, LangdetectProfileRequestBuilder> { | ||
|
||
public static final String NAME = "langdetect.profile"; | ||
|
||
public static final LangdetectProfileAction INSTANCE = new LangdetectProfileAction(); | ||
|
||
private LangdetectProfileAction() { | ||
super(NAME); | ||
} | ||
|
||
@Override | ||
public LangdetectProfileRequestBuilder newRequestBuilder(IndicesAdminClient client) { | ||
return new LangdetectProfileRequestBuilder(client); | ||
} | ||
|
||
@Override | ||
public LangdetectProfileResponse newResponse() { | ||
return new LangdetectProfileResponse(); | ||
} | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
src/main/java/org/xbib/elasticsearch/action/langdetect/profile/LangdetectProfileRequest.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,36 @@ | ||
package org.xbib.elasticsearch.action.langdetect.profile; | ||
|
||
import org.elasticsearch.action.support.single.custom.SingleCustomOperationRequest; | ||
import org.elasticsearch.common.io.stream.StreamInput; | ||
import org.elasticsearch.common.io.stream.StreamOutput; | ||
|
||
import java.io.IOException; | ||
|
||
public class LangdetectProfileRequest extends SingleCustomOperationRequest<LangdetectProfileRequest> { | ||
|
||
private String profile; | ||
|
||
public LangdetectProfileRequest() { | ||
} | ||
|
||
public LangdetectProfileRequest setProfile(String profile) { | ||
this.profile = profile; | ||
return this; | ||
} | ||
|
||
public String getProfile() { | ||
return profile; | ||
} | ||
|
||
@Override | ||
public void readFrom(StreamInput in) throws IOException { | ||
super.readFrom(in); | ||
profile = in.readString(); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
out.writeString(profile); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...ava/org/xbib/elasticsearch/action/langdetect/profile/LangdetectProfileRequestBuilder.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,23 @@ | ||
package org.xbib.elasticsearch.action.langdetect.profile; | ||
|
||
import org.elasticsearch.action.ActionListener; | ||
import org.elasticsearch.action.support.single.custom.SingleCustomOperationRequestBuilder; | ||
import org.elasticsearch.client.IndicesAdminClient; | ||
|
||
public class LangdetectProfileRequestBuilder extends SingleCustomOperationRequestBuilder<LangdetectProfileRequest, LangdetectProfileResponse, LangdetectProfileRequestBuilder> { | ||
|
||
public LangdetectProfileRequestBuilder(IndicesAdminClient client) { | ||
super(client, new LangdetectProfileRequest()); | ||
} | ||
|
||
public LangdetectProfileRequestBuilder setProfile(String string) { | ||
request.setProfile(string); | ||
return this; | ||
} | ||
|
||
@Override | ||
protected void doExecute(ActionListener<LangdetectProfileResponse> listener) { | ||
client.execute(LangdetectProfileAction.INSTANCE, request, listener); | ||
} | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
...main/java/org/xbib/elasticsearch/action/langdetect/profile/LangdetectProfileResponse.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,27 @@ | ||
package org.xbib.elasticsearch.action.langdetect.profile; | ||
|
||
import org.elasticsearch.action.ActionResponse; | ||
import org.elasticsearch.common.xcontent.StatusToXContent; | ||
import org.elasticsearch.common.xcontent.XContentBuilder; | ||
import org.elasticsearch.rest.RestStatus; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.elasticsearch.rest.RestStatus.OK; | ||
|
||
public class LangdetectProfileResponse extends ActionResponse implements StatusToXContent { | ||
|
||
public LangdetectProfileResponse() { | ||
} | ||
|
||
@Override | ||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
builder.field("ok", true); | ||
return builder; | ||
} | ||
|
||
@Override | ||
public RestStatus status() { | ||
return OK; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...va/org/xbib/elasticsearch/action/langdetect/profile/TransportLangdetectProfileAction.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,32 @@ | ||
package org.xbib.elasticsearch.action.langdetect.profile; | ||
|
||
import org.elasticsearch.action.ActionListener; | ||
import org.elasticsearch.action.support.ActionFilters; | ||
import org.elasticsearch.action.support.TransportAction; | ||
import org.elasticsearch.common.inject.Inject; | ||
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.threadpool.ThreadPool; | ||
import org.xbib.elasticsearch.index.analysis.langdetect.LanguageDetectionException; | ||
import org.xbib.elasticsearch.module.langdetect.LangdetectService; | ||
|
||
public class TransportLangdetectProfileAction extends TransportAction<LangdetectProfileRequest, LangdetectProfileResponse> { | ||
|
||
private final LangdetectService service; | ||
|
||
@Inject | ||
public TransportLangdetectProfileAction(Settings settings, ThreadPool threadPool, | ||
ActionFilters actionFilters, LangdetectService service) { | ||
super(settings, LangdetectProfileAction.NAME, threadPool, actionFilters); | ||
this.service = service; | ||
} | ||
|
||
@Override | ||
protected void doExecute(LangdetectProfileRequest request, ActionListener<LangdetectProfileResponse> listener) { | ||
try { | ||
service.setProfile(request.getProfile()); | ||
listener.onResponse(new LangdetectProfileResponse()); | ||
} catch (LanguageDetectionException e) { | ||
listener.onFailure(e); | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/org/xbib/elasticsearch/module/langdetect/LangdetectIndexModule.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,13 @@ | ||
package org.xbib.elasticsearch.module.langdetect; | ||
|
||
import org.elasticsearch.common.inject.Binder; | ||
import org.elasticsearch.common.inject.Module; | ||
|
||
public class LangdetectIndexModule implements Module { | ||
|
||
@Override | ||
public void configure(Binder binder) { | ||
binder.bind(RegisterLangdetectType.class).asEagerSingleton(); | ||
} | ||
|
||
} |
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.