-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refs #583410 - Coma now can issue code resources to the above layers …
…but no notifications on changes.
- Loading branch information
1 parent
69abb0b
commit ae8ed5f
Showing
4 changed files
with
194 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* | ||
* Copyright 2016 Martin Goellnitz | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
package org.tangram.coma; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.InputStream; | ||
import java.util.Map; | ||
import org.tangram.content.CodeResource; | ||
|
||
|
||
/** | ||
* Code implementation in the Coma context. | ||
*/ | ||
public class ComaCode extends ComaContent implements CodeResource { | ||
|
||
public ComaCode(String id, String type, Map<String, Object> properties) { | ||
super(id, type, properties); | ||
} // () | ||
|
||
|
||
@Override | ||
public String getAnnotation() { | ||
return ""+get("annotation"); | ||
} | ||
|
||
|
||
@Override | ||
public String getMimeType() { | ||
return ""+get("mimeType"); | ||
} | ||
|
||
|
||
@Override | ||
public String getCodeText() { | ||
return ""+get("code"); | ||
} | ||
|
||
|
||
@Override | ||
public long getModificationTime() { | ||
return (Long)get("modificationTime"); | ||
} | ||
|
||
|
||
@Override | ||
public long getSize() { | ||
return getCodeText().length(); | ||
} // getSize() | ||
|
||
|
||
@Override | ||
public InputStream getStream() throws Exception { | ||
return new ByteArrayInputStream(getCodeText().getBytes("UTF-8")); | ||
} // getStream() | ||
|
||
} // ComaCode |
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
45 changes: 45 additions & 0 deletions
45
coma/test/org/tangram/components/coma/test/ComaTestCodeBeanPopulator.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,45 @@ | ||
/* | ||
* | ||
* Copyright 2016 Martin Goellnitz | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
package org.tangram.components.coma.test; | ||
|
||
import java.util.Date; | ||
import javax.inject.Named; | ||
import javax.inject.Singleton; | ||
import org.tangram.coma.ComaBeanPopulator; | ||
import org.tangram.coma.ComaContent; | ||
|
||
|
||
/** | ||
* Dummy population of beans as code. | ||
*/ | ||
@Named | ||
@Singleton | ||
public class ComaTestCodeBeanPopulator implements ComaBeanPopulator { | ||
|
||
@Override | ||
public void populate(ComaContent content) { | ||
if ("Topic".equals(content.getDocumentType())) { | ||
content.put("annotation", "org.tangram.example.Topic"); | ||
content.put("mimeType", "text/html"); | ||
content.put("code", "<html><head><title>Test</title></head><body></body></html>"); | ||
content.put("modificationTime", new Date().getTime()); | ||
} // if | ||
} // populate() | ||
|
||
} // ComaTestCodeBeanPopulator |