This repository has been archived by the owner on Apr 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use an xml (de)serializer to create Java object instead of parsing th…
…em by hand
- Loading branch information
Laurent Clouet
committed
Sep 3, 2019
1 parent
52ad13c
commit 81cba7d
Showing
12 changed files
with
424 additions
and
307 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
Large diffs are not rendered by default.
Oops, something went wrong.
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,20 @@ | ||
package com.sheepit.client.datamodel; | ||
|
||
import lombok.Data; | ||
import lombok.ToString; | ||
import org.simpleframework.xml.ElementList; | ||
import org.simpleframework.xml.Root; | ||
|
||
import java.util.List; | ||
|
||
@Root(strict = false, name = "cache") | ||
@Data | ||
@ToString | ||
public class CacheFileMD5 { | ||
|
||
@ElementList(inline = true) | ||
private List<FileMD5> md5s; | ||
|
||
public CacheFileMD5() { | ||
} | ||
} |
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,21 @@ | ||
package com.sheepit.client.datamodel; | ||
|
||
import lombok.Data; | ||
import lombok.ToString; | ||
import org.simpleframework.xml.Attribute; | ||
import org.simpleframework.xml.Root; | ||
|
||
@Root(strict = false, name = "file") | ||
@Data | ||
@ToString | ||
public class FileMD5 { | ||
|
||
@Attribute | ||
private String md5; | ||
|
||
@Attribute(required = false) | ||
private String action; | ||
|
||
public FileMD5() { | ||
} | ||
} |
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,14 @@ | ||
package com.sheepit.client.datamodel; | ||
|
||
import lombok.Getter; | ||
import lombok.ToString; | ||
import org.simpleframework.xml.Attribute; | ||
import org.simpleframework.xml.Root; | ||
|
||
@Root(strict = false, name = "keepmealive") | ||
@ToString | ||
public class HeartBeatInfos { | ||
@Attribute | ||
@Getter | ||
private int status; | ||
} |
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,34 @@ | ||
package com.sheepit.client.datamodel; | ||
|
||
import lombok.Getter; | ||
import lombok.ToString; | ||
import org.simpleframework.xml.Attribute; | ||
import org.simpleframework.xml.Element; | ||
import org.simpleframework.xml.ElementList; | ||
import org.simpleframework.xml.Root; | ||
|
||
import java.util.List; | ||
|
||
@Root(strict = false, name = "jobrequest") | ||
@ToString | ||
public class JobInfos { | ||
|
||
@Attribute | ||
@Getter | ||
private int status; | ||
|
||
@Element(name = "stats", required = false) | ||
@Getter | ||
private SessionStats sessionStats; | ||
|
||
@Element(name = "job", required = false) | ||
@Getter() | ||
private RenderTask renderTask; | ||
|
||
@ElementList(name = "file", inline = true, required = false) | ||
@Getter | ||
private List<FileMD5> fileMD5s; | ||
|
||
public JobInfos() { | ||
} | ||
} |
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,18 @@ | ||
package com.sheepit.client.datamodel; | ||
|
||
import lombok.Getter; | ||
import lombok.ToString; | ||
import org.simpleframework.xml.Attribute; | ||
import org.simpleframework.xml.Root; | ||
|
||
@Root(strict = false, name = "jobvalidate") | ||
@ToString | ||
public class JobValidation { | ||
|
||
@Attribute | ||
@Getter | ||
private int status; | ||
|
||
public JobValidation() { | ||
} | ||
} |
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,60 @@ | ||
package com.sheepit.client.datamodel; | ||
|
||
import lombok.Getter; | ||
import lombok.ToString; | ||
import org.simpleframework.xml.Attribute; | ||
import org.simpleframework.xml.Element; | ||
import org.simpleframework.xml.Root; | ||
|
||
@Root(strict = false, name = "job") | ||
@ToString | ||
public class RenderTask { | ||
|
||
@Attribute(name = "id") | ||
@Getter | ||
private String id; | ||
|
||
@Attribute(name = "use_gpu") | ||
@Getter | ||
private int useGpu; | ||
|
||
@Attribute(name = "archive_md5") | ||
@Getter | ||
private String archive_md5; | ||
|
||
@Attribute(name = "path") | ||
@Getter | ||
private String path; | ||
|
||
@Attribute(name = "frame") | ||
@Getter | ||
private String frame; | ||
|
||
@Attribute(name = "synchronous_upload") | ||
@Getter | ||
private String synchronous_upload; | ||
|
||
@Attribute(name = "extras") | ||
@Getter | ||
private String extras; | ||
|
||
@Attribute(name = "name") | ||
@Getter | ||
private String name; | ||
|
||
@Attribute(name = "password") | ||
@Getter | ||
private String password; | ||
|
||
@Element(name = "renderer") | ||
@Getter | ||
private RendererInfos rendererInfos; | ||
|
||
@Element(name = "script", data = true) | ||
@Getter | ||
private String script; | ||
|
||
public RenderTask() { | ||
|
||
} | ||
} |
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 com.sheepit.client.datamodel; | ||
|
||
import lombok.Getter; | ||
import lombok.ToString; | ||
import org.simpleframework.xml.Attribute; | ||
import org.simpleframework.xml.Root; | ||
|
||
@Root(strict = false, name = "renderer") | ||
@ToString | ||
public class RendererInfos { | ||
|
||
@Attribute(name = "md5") | ||
@Getter | ||
private String md5; | ||
|
||
@Attribute(name = "commandline") | ||
@Getter | ||
private String commandline; | ||
|
||
@Attribute(name = "update_method") | ||
@Getter | ||
private String update_method; | ||
|
||
public RendererInfos() { | ||
|
||
} | ||
} |
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 com.sheepit.client.datamodel; | ||
|
||
import lombok.Getter; | ||
import lombok.ToString; | ||
import org.simpleframework.xml.Attribute; | ||
import org.simpleframework.xml.Root; | ||
|
||
@Root(strict = false, name = "request") | ||
@ToString | ||
public class RequestEndPoint { | ||
|
||
@Attribute | ||
@Getter | ||
private String type; | ||
|
||
@Attribute | ||
@Getter | ||
private String path; | ||
|
||
@Attribute(name = "max-period", required = false) | ||
@Getter | ||
private int maxPeriod; | ||
|
||
public RequestEndPoint() { | ||
} | ||
} |
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 @@ | ||
package com.sheepit.client.datamodel; | ||
|
||
import lombok.Getter; | ||
import lombok.ToString; | ||
import org.simpleframework.xml.Attribute; | ||
import org.simpleframework.xml.ElementList; | ||
import org.simpleframework.xml.Root; | ||
|
||
import java.util.List; | ||
|
||
@Root(strict = false, name = "config") | ||
@ToString | ||
public class ServerConfig { | ||
|
||
@Attribute | ||
@Getter | ||
private int status; | ||
|
||
@Attribute | ||
@Getter | ||
private String publickey; | ||
|
||
@ElementList(name = "request", inline = true, required = false) | ||
private List<RequestEndPoint> requestEndPoints; | ||
|
||
public ServerConfig() { | ||
} | ||
|
||
public RequestEndPoint getRequestEndPoint(String type) { | ||
if (requestEndPoints != null) { | ||
for (RequestEndPoint endPoint : requestEndPoints) { | ||
if (type.equals(endPoint.getType())) { | ||
return endPoint; | ||
} | ||
} | ||
} | ||
return null; | ||
} | ||
} |
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 @@ | ||
package com.sheepit.client.datamodel; | ||
|
||
import lombok.Getter; | ||
import lombok.ToString; | ||
import org.simpleframework.xml.Attribute; | ||
import org.simpleframework.xml.Root; | ||
|
||
@Root(strict = false, name = "stats") | ||
@ToString | ||
public class SessionStats { | ||
|
||
@Attribute(name = "credits_session") | ||
@Getter | ||
private int pointsEarnedOnSession; | ||
|
||
@Attribute(name = "credits_total") | ||
@Getter | ||
private int pointsEarnedByUser; | ||
|
||
@Attribute(name = "frame_remaining") | ||
@Getter | ||
private int remainingFrames; | ||
|
||
@Attribute(name = "waiting_project") | ||
@Getter | ||
private int waitingProjects; | ||
|
||
@Attribute(name = "renderable_project", required = false) | ||
@Getter | ||
private int renderableProjects; | ||
|
||
@Attribute(name = "connected_machine") | ||
@Getter | ||
private int connectedMachines; | ||
|
||
public SessionStats() { | ||
|
||
} | ||
} |