repo_name
stringlengths
7
104
file_path
stringlengths
13
198
context
stringlengths
67
7.15k
import_statement
stringlengths
16
4.43k
code
stringlengths
40
6.98k
prompt
stringlengths
227
8.27k
next_line
stringlengths
8
795
jimmc/HapiPodcastJ
src/info/xuluan/podcast/tests/ResponseTest.java
// Path: src/info/xuluan/podcast/fetcher/Response.java // public class Response { // private final Log log = Log.getLog(getClass()); // // public final byte[] content; // // public Response(byte[] content) { // this.content = content; // } // // public String getCharset(){ // if(content==null) // return "ISO-8859-1"; // // Pattern p = Pattern.compile("\\<\\?xml.*?encoding\\=\"(.*?)\"\\s*\\?\\>" // ,Pattern.CASE_INSENSITIVE + Pattern.MULTILINE); // int length = content.length>100?100:content.length; // String line = new String(content, 0, length); // Matcher m = p.matcher(line); // // if (m.find()){ // log.debug("Charset = " + m.group(1)); // return m.group(1); // } // return "ISO-8859-1"; // } // // public String getContentAsString() throws UnsupportedEncodingException { // // //String enc = charset == null ? "ISO-8859-1" : charset; // String charset = getCharset(); // String text; // // try { // text = new String(content, charset); // }catch (Exception e) { // text = new String(content, "UTF-8"); // } // // return text; // } // // }
import info.xuluan.podcast.fetcher.Response; import junit.framework.TestCase;
/* * Copyright (C) 2008 The Android Open Source Project * * 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 info.xuluan.podcast.tests; public class ResponseTest extends TestCase { public void testGetCharset_ISO_8859_1() throws Exception { String s = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
// Path: src/info/xuluan/podcast/fetcher/Response.java // public class Response { // private final Log log = Log.getLog(getClass()); // // public final byte[] content; // // public Response(byte[] content) { // this.content = content; // } // // public String getCharset(){ // if(content==null) // return "ISO-8859-1"; // // Pattern p = Pattern.compile("\\<\\?xml.*?encoding\\=\"(.*?)\"\\s*\\?\\>" // ,Pattern.CASE_INSENSITIVE + Pattern.MULTILINE); // int length = content.length>100?100:content.length; // String line = new String(content, 0, length); // Matcher m = p.matcher(line); // // if (m.find()){ // log.debug("Charset = " + m.group(1)); // return m.group(1); // } // return "ISO-8859-1"; // } // // public String getContentAsString() throws UnsupportedEncodingException { // // //String enc = charset == null ? "ISO-8859-1" : charset; // String charset = getCharset(); // String text; // // try { // text = new String(content, charset); // }catch (Exception e) { // text = new String(content, "UTF-8"); // } // // return text; // } // // } // Path: src/info/xuluan/podcast/tests/ResponseTest.java import info.xuluan.podcast.fetcher.Response; import junit.framework.TestCase; /* * Copyright (C) 2008 The Android Open Source Project * * 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 info.xuluan.podcast.tests; public class ResponseTest extends TestCase { public void testGetCharset_ISO_8859_1() throws Exception { String s = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
Response res = new Response(s.getBytes());
jimmc/HapiPodcastJ
src/info/xuluan/podcast/tests/SDCardTest.java
// Path: src/info/xuluan/podcast/utils/SDCardMgr.java // public class SDCardMgr { // // public static String SDCARD_DIR = // Environment.getExternalStorageDirectory().getPath(); //e.g. /sdcard // public static final String APP_DIR = "/xuluan.podcast"; // public static final String DOWNLOAD_DIR = "/download"; // public static final String EXPORT_DIR = "/export"; // // public static boolean getSDCardStatus() // { // return android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED); // } // // public static boolean getSDCardStatusAndCreate() // { // boolean b = getSDCardStatus(); // if(b) // createDir(); // return b; // } // // public static String getExportDir() // { // File sdDir = new File(Environment.getExternalStorageDirectory().getPath()); // SDCARD_DIR = sdDir.getAbsolutePath(); // return SDCARD_DIR + APP_DIR + EXPORT_DIR; // } // // public static String getDownloadDir() // { // File sdDir = new File(Environment.getExternalStorageDirectory().getPath()); // SDCARD_DIR = sdDir.getAbsolutePath(); // return SDCARD_DIR + APP_DIR + DOWNLOAD_DIR; // } // // public static String getAppDir() // { // File sdDir = new File(Environment.getExternalStorageDirectory().getPath()); // SDCARD_DIR = sdDir.getAbsolutePath(); // return SDCARD_DIR + APP_DIR; // } // // // private static boolean createDir() // { // File file = new File(getDownloadDir()); // boolean exists = (file.exists()); // if (!exists) { // return file.mkdirs(); // } // // file = new File(getExportDir()); // exists = (file.exists()); // if (!exists) { // return file.mkdirs(); // } // return true; // } // // }
import junit.framework.TestCase; import info.xuluan.podcast.utils.SDCardMgr;
/* * Copyright (C) 2008 The Android Open Source Project * * 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 info.xuluan.podcast.tests; public class SDCardTest extends TestCase { public void testAppDir() throws Exception {
// Path: src/info/xuluan/podcast/utils/SDCardMgr.java // public class SDCardMgr { // // public static String SDCARD_DIR = // Environment.getExternalStorageDirectory().getPath(); //e.g. /sdcard // public static final String APP_DIR = "/xuluan.podcast"; // public static final String DOWNLOAD_DIR = "/download"; // public static final String EXPORT_DIR = "/export"; // // public static boolean getSDCardStatus() // { // return android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED); // } // // public static boolean getSDCardStatusAndCreate() // { // boolean b = getSDCardStatus(); // if(b) // createDir(); // return b; // } // // public static String getExportDir() // { // File sdDir = new File(Environment.getExternalStorageDirectory().getPath()); // SDCARD_DIR = sdDir.getAbsolutePath(); // return SDCARD_DIR + APP_DIR + EXPORT_DIR; // } // // public static String getDownloadDir() // { // File sdDir = new File(Environment.getExternalStorageDirectory().getPath()); // SDCARD_DIR = sdDir.getAbsolutePath(); // return SDCARD_DIR + APP_DIR + DOWNLOAD_DIR; // } // // public static String getAppDir() // { // File sdDir = new File(Environment.getExternalStorageDirectory().getPath()); // SDCARD_DIR = sdDir.getAbsolutePath(); // return SDCARD_DIR + APP_DIR; // } // // // private static boolean createDir() // { // File file = new File(getDownloadDir()); // boolean exists = (file.exists()); // if (!exists) { // return file.mkdirs(); // } // // file = new File(getExportDir()); // exists = (file.exists()); // if (!exists) { // return file.mkdirs(); // } // return true; // } // // } // Path: src/info/xuluan/podcast/tests/SDCardTest.java import junit.framework.TestCase; import info.xuluan.podcast.utils.SDCardMgr; /* * Copyright (C) 2008 The Android Open Source Project * * 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 info.xuluan.podcast.tests; public class SDCardTest extends TestCase { public void testAppDir() throws Exception {
assertTrue(SDCardMgr.getAppDir().equals("/mnt/sdcard/xuluan.podcast"));
indeedeng/proctor-webapp-library
src/main/java/com/indeed/proctor/webapp/tags/RenderDefinitionDetailsPageInjectionTemplatesHandler.java
// Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/DefinitionDetailsPageRenderer.java // public interface DefinitionDetailsPageRenderer { // enum DefinitionDetailsPagePosition { // TOP, // MIDDLE, // BOTTOM // } // // DefinitionDetailsPagePosition getDefinitionDetailsPagePosition(); // // @Deprecated // default String getRenderedHtml(final String testName, final TestDefinition testDefinition){ // return ""; // } // // default String getRenderedHtml(final PageContext pageContext, final String testName, final TestDefinition testDefinition){ // return ""; // } // } // // Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/DefinitionDetailsPageRenderer.java // enum DefinitionDetailsPagePosition { // TOP, // MIDDLE, // BOTTOM // }
import com.indeed.proctor.common.model.TestDefinition; import com.indeed.proctor.webapp.extensions.renderer.DefinitionDetailsPageRenderer; import com.indeed.proctor.webapp.extensions.renderer.DefinitionDetailsPageRenderer.DefinitionDetailsPagePosition; import org.apache.log4j.Logger; import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; import javax.servlet.ServletContext; import javax.servlet.jsp.tagext.TagSupport; import java.io.IOException; import java.util.Map;
package com.indeed.proctor.webapp.tags; /** */ public class RenderDefinitionDetailsPageInjectionTemplatesHandler extends TagSupport { private static final Logger LOGGER = Logger.getLogger(RenderDefinitionDetailsPageInjectionTemplatesHandler.class);
// Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/DefinitionDetailsPageRenderer.java // public interface DefinitionDetailsPageRenderer { // enum DefinitionDetailsPagePosition { // TOP, // MIDDLE, // BOTTOM // } // // DefinitionDetailsPagePosition getDefinitionDetailsPagePosition(); // // @Deprecated // default String getRenderedHtml(final String testName, final TestDefinition testDefinition){ // return ""; // } // // default String getRenderedHtml(final PageContext pageContext, final String testName, final TestDefinition testDefinition){ // return ""; // } // } // // Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/DefinitionDetailsPageRenderer.java // enum DefinitionDetailsPagePosition { // TOP, // MIDDLE, // BOTTOM // } // Path: src/main/java/com/indeed/proctor/webapp/tags/RenderDefinitionDetailsPageInjectionTemplatesHandler.java import com.indeed.proctor.common.model.TestDefinition; import com.indeed.proctor.webapp.extensions.renderer.DefinitionDetailsPageRenderer; import com.indeed.proctor.webapp.extensions.renderer.DefinitionDetailsPageRenderer.DefinitionDetailsPagePosition; import org.apache.log4j.Logger; import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; import javax.servlet.ServletContext; import javax.servlet.jsp.tagext.TagSupport; import java.io.IOException; import java.util.Map; package com.indeed.proctor.webapp.tags; /** */ public class RenderDefinitionDetailsPageInjectionTemplatesHandler extends TagSupport { private static final Logger LOGGER = Logger.getLogger(RenderDefinitionDetailsPageInjectionTemplatesHandler.class);
private DefinitionDetailsPagePosition position;
indeedeng/proctor-webapp-library
src/main/java/com/indeed/proctor/webapp/tags/RenderDefinitionDetailsPageInjectionTemplatesHandler.java
// Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/DefinitionDetailsPageRenderer.java // public interface DefinitionDetailsPageRenderer { // enum DefinitionDetailsPagePosition { // TOP, // MIDDLE, // BOTTOM // } // // DefinitionDetailsPagePosition getDefinitionDetailsPagePosition(); // // @Deprecated // default String getRenderedHtml(final String testName, final TestDefinition testDefinition){ // return ""; // } // // default String getRenderedHtml(final PageContext pageContext, final String testName, final TestDefinition testDefinition){ // return ""; // } // } // // Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/DefinitionDetailsPageRenderer.java // enum DefinitionDetailsPagePosition { // TOP, // MIDDLE, // BOTTOM // }
import com.indeed.proctor.common.model.TestDefinition; import com.indeed.proctor.webapp.extensions.renderer.DefinitionDetailsPageRenderer; import com.indeed.proctor.webapp.extensions.renderer.DefinitionDetailsPageRenderer.DefinitionDetailsPagePosition; import org.apache.log4j.Logger; import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; import javax.servlet.ServletContext; import javax.servlet.jsp.tagext.TagSupport; import java.io.IOException; import java.util.Map;
package com.indeed.proctor.webapp.tags; /** */ public class RenderDefinitionDetailsPageInjectionTemplatesHandler extends TagSupport { private static final Logger LOGGER = Logger.getLogger(RenderDefinitionDetailsPageInjectionTemplatesHandler.class); private DefinitionDetailsPagePosition position; private String testName; private TestDefinition testDefinition; public void setPosition(final DefinitionDetailsPagePosition position) { this.position = position; } public void setTestName(final String testName) { this.testName = testName; } public void setTestDefinition(final TestDefinition testDefinition) { this.testDefinition = testDefinition; } public int doStartTag() { try { pageContext.getOut().print(renderTemplates()); } catch (IOException e) { LOGGER.error("Failed to write rendered html to page context", e); } return SKIP_BODY; } private String renderTemplates() { final StringBuilder renderedHTML = new StringBuilder(); final ServletContext servletContext = pageContext.getServletContext(); final WebApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext); try {
// Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/DefinitionDetailsPageRenderer.java // public interface DefinitionDetailsPageRenderer { // enum DefinitionDetailsPagePosition { // TOP, // MIDDLE, // BOTTOM // } // // DefinitionDetailsPagePosition getDefinitionDetailsPagePosition(); // // @Deprecated // default String getRenderedHtml(final String testName, final TestDefinition testDefinition){ // return ""; // } // // default String getRenderedHtml(final PageContext pageContext, final String testName, final TestDefinition testDefinition){ // return ""; // } // } // // Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/DefinitionDetailsPageRenderer.java // enum DefinitionDetailsPagePosition { // TOP, // MIDDLE, // BOTTOM // } // Path: src/main/java/com/indeed/proctor/webapp/tags/RenderDefinitionDetailsPageInjectionTemplatesHandler.java import com.indeed.proctor.common.model.TestDefinition; import com.indeed.proctor.webapp.extensions.renderer.DefinitionDetailsPageRenderer; import com.indeed.proctor.webapp.extensions.renderer.DefinitionDetailsPageRenderer.DefinitionDetailsPagePosition; import org.apache.log4j.Logger; import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; import javax.servlet.ServletContext; import javax.servlet.jsp.tagext.TagSupport; import java.io.IOException; import java.util.Map; package com.indeed.proctor.webapp.tags; /** */ public class RenderDefinitionDetailsPageInjectionTemplatesHandler extends TagSupport { private static final Logger LOGGER = Logger.getLogger(RenderDefinitionDetailsPageInjectionTemplatesHandler.class); private DefinitionDetailsPagePosition position; private String testName; private TestDefinition testDefinition; public void setPosition(final DefinitionDetailsPagePosition position) { this.position = position; } public void setTestName(final String testName) { this.testName = testName; } public void setTestDefinition(final TestDefinition testDefinition) { this.testDefinition = testDefinition; } public int doStartTag() { try { pageContext.getOut().print(renderTemplates()); } catch (IOException e) { LOGGER.error("Failed to write rendered html to page context", e); } return SKIP_BODY; } private String renderTemplates() { final StringBuilder renderedHTML = new StringBuilder(); final ServletContext servletContext = pageContext.getServletContext(); final WebApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext); try {
final Map<String, DefinitionDetailsPageRenderer> rendererBeans = BeanFactoryUtils.beansOfTypeIncludingAncestors(context, DefinitionDetailsPageRenderer.class);
indeedeng/proctor-webapp-library
src/main/java/com/indeed/proctor/webapp/jobs/BackgroundJobFactory.java
// Path: src/main/java/com/indeed/proctor/webapp/extensions/AfterBackgroundJobExecute.java // public interface AfterBackgroundJobExecute { // <T> void afterExecute(final BackgroundJob<T> job, T result); // } // // Path: src/main/java/com/indeed/proctor/webapp/extensions/BeforeBackgroundJobExecute.java // public interface BeforeBackgroundJobExecute { // <T> void beforeExecute(final BackgroundJob<T> job); // }
import com.indeed.proctor.webapp.extensions.AfterBackgroundJobExecute; import com.indeed.proctor.webapp.extensions.BeforeBackgroundJobExecute; import org.springframework.beans.factory.annotation.Autowired; import java.util.Collections; import java.util.List;
package com.indeed.proctor.webapp.jobs; public class BackgroundJobFactory { @Autowired(required = false)
// Path: src/main/java/com/indeed/proctor/webapp/extensions/AfterBackgroundJobExecute.java // public interface AfterBackgroundJobExecute { // <T> void afterExecute(final BackgroundJob<T> job, T result); // } // // Path: src/main/java/com/indeed/proctor/webapp/extensions/BeforeBackgroundJobExecute.java // public interface BeforeBackgroundJobExecute { // <T> void beforeExecute(final BackgroundJob<T> job); // } // Path: src/main/java/com/indeed/proctor/webapp/jobs/BackgroundJobFactory.java import com.indeed.proctor.webapp.extensions.AfterBackgroundJobExecute; import com.indeed.proctor.webapp.extensions.BeforeBackgroundJobExecute; import org.springframework.beans.factory.annotation.Autowired; import java.util.Collections; import java.util.List; package com.indeed.proctor.webapp.jobs; public class BackgroundJobFactory { @Autowired(required = false)
private List<BeforeBackgroundJobExecute> beforeBackgroundJobExecutes = Collections.emptyList();
indeedeng/proctor-webapp-library
src/main/java/com/indeed/proctor/webapp/jobs/BackgroundJobFactory.java
// Path: src/main/java/com/indeed/proctor/webapp/extensions/AfterBackgroundJobExecute.java // public interface AfterBackgroundJobExecute { // <T> void afterExecute(final BackgroundJob<T> job, T result); // } // // Path: src/main/java/com/indeed/proctor/webapp/extensions/BeforeBackgroundJobExecute.java // public interface BeforeBackgroundJobExecute { // <T> void beforeExecute(final BackgroundJob<T> job); // }
import com.indeed.proctor.webapp.extensions.AfterBackgroundJobExecute; import com.indeed.proctor.webapp.extensions.BeforeBackgroundJobExecute; import org.springframework.beans.factory.annotation.Autowired; import java.util.Collections; import java.util.List;
package com.indeed.proctor.webapp.jobs; public class BackgroundJobFactory { @Autowired(required = false) private List<BeforeBackgroundJobExecute> beforeBackgroundJobExecutes = Collections.emptyList(); @Autowired(required = false)
// Path: src/main/java/com/indeed/proctor/webapp/extensions/AfterBackgroundJobExecute.java // public interface AfterBackgroundJobExecute { // <T> void afterExecute(final BackgroundJob<T> job, T result); // } // // Path: src/main/java/com/indeed/proctor/webapp/extensions/BeforeBackgroundJobExecute.java // public interface BeforeBackgroundJobExecute { // <T> void beforeExecute(final BackgroundJob<T> job); // } // Path: src/main/java/com/indeed/proctor/webapp/jobs/BackgroundJobFactory.java import com.indeed.proctor.webapp.extensions.AfterBackgroundJobExecute; import com.indeed.proctor.webapp.extensions.BeforeBackgroundJobExecute; import org.springframework.beans.factory.annotation.Autowired; import java.util.Collections; import java.util.List; package com.indeed.proctor.webapp.jobs; public class BackgroundJobFactory { @Autowired(required = false) private List<BeforeBackgroundJobExecute> beforeBackgroundJobExecutes = Collections.emptyList(); @Autowired(required = false)
private List<AfterBackgroundJobExecute> afterBackgroundJobExecutes = Collections.emptyList();
indeedeng/proctor-webapp-library
src/main/java/com/indeed/proctor/webapp/jobs/BackgroundJob.java
// Path: src/main/java/com/indeed/proctor/webapp/extensions/AfterBackgroundJobExecute.java // public interface AfterBackgroundJobExecute { // <T> void afterExecute(final BackgroundJob<T> job, T result); // } // // Path: src/main/java/com/indeed/proctor/webapp/extensions/BeforeBackgroundJobExecute.java // public interface BeforeBackgroundJobExecute { // <T> void beforeExecute(final BackgroundJob<T> job); // }
import com.google.common.collect.Lists; import com.indeed.proctor.webapp.extensions.AfterBackgroundJobExecute; import com.indeed.proctor.webapp.extensions.BeforeBackgroundJobExecute; import org.apache.log4j.Logger; import javax.annotation.Nonnull; import java.util.List; import java.util.UUID; import java.util.concurrent.Callable; import java.util.concurrent.Future;
setError(t); } } public static class ResultUrl { private final String href; private final String text; private final String target; public ResultUrl(final String href, final String text, final String target) { this.href = href; this.text = text; this.target = target; } public String getHref() { return href; } public String getTarget() { return target; } public String getText() { return text; } }
// Path: src/main/java/com/indeed/proctor/webapp/extensions/AfterBackgroundJobExecute.java // public interface AfterBackgroundJobExecute { // <T> void afterExecute(final BackgroundJob<T> job, T result); // } // // Path: src/main/java/com/indeed/proctor/webapp/extensions/BeforeBackgroundJobExecute.java // public interface BeforeBackgroundJobExecute { // <T> void beforeExecute(final BackgroundJob<T> job); // } // Path: src/main/java/com/indeed/proctor/webapp/jobs/BackgroundJob.java import com.google.common.collect.Lists; import com.indeed.proctor.webapp.extensions.AfterBackgroundJobExecute; import com.indeed.proctor.webapp.extensions.BeforeBackgroundJobExecute; import org.apache.log4j.Logger; import javax.annotation.Nonnull; import java.util.List; import java.util.UUID; import java.util.concurrent.Callable; import java.util.concurrent.Future; setError(t); } } public static class ResultUrl { private final String href; private final String text; private final String target; public ResultUrl(final String href, final String text, final String target) { this.href = href; this.text = text; this.target = target; } public String getHref() { return href; } public String getTarget() { return target; } public String getText() { return text; } }
protected abstract List<BeforeBackgroundJobExecute> getBeforeBackgroundJobExecutes();
indeedeng/proctor-webapp-library
src/main/java/com/indeed/proctor/webapp/jobs/BackgroundJob.java
// Path: src/main/java/com/indeed/proctor/webapp/extensions/AfterBackgroundJobExecute.java // public interface AfterBackgroundJobExecute { // <T> void afterExecute(final BackgroundJob<T> job, T result); // } // // Path: src/main/java/com/indeed/proctor/webapp/extensions/BeforeBackgroundJobExecute.java // public interface BeforeBackgroundJobExecute { // <T> void beforeExecute(final BackgroundJob<T> job); // }
import com.google.common.collect.Lists; import com.indeed.proctor.webapp.extensions.AfterBackgroundJobExecute; import com.indeed.proctor.webapp.extensions.BeforeBackgroundJobExecute; import org.apache.log4j.Logger; import javax.annotation.Nonnull; import java.util.List; import java.util.UUID; import java.util.concurrent.Callable; import java.util.concurrent.Future;
} public static class ResultUrl { private final String href; private final String text; private final String target; public ResultUrl(final String href, final String text, final String target) { this.href = href; this.text = text; this.target = target; } public String getHref() { return href; } public String getTarget() { return target; } public String getText() { return text; } } protected abstract List<BeforeBackgroundJobExecute> getBeforeBackgroundJobExecutes();
// Path: src/main/java/com/indeed/proctor/webapp/extensions/AfterBackgroundJobExecute.java // public interface AfterBackgroundJobExecute { // <T> void afterExecute(final BackgroundJob<T> job, T result); // } // // Path: src/main/java/com/indeed/proctor/webapp/extensions/BeforeBackgroundJobExecute.java // public interface BeforeBackgroundJobExecute { // <T> void beforeExecute(final BackgroundJob<T> job); // } // Path: src/main/java/com/indeed/proctor/webapp/jobs/BackgroundJob.java import com.google.common.collect.Lists; import com.indeed.proctor.webapp.extensions.AfterBackgroundJobExecute; import com.indeed.proctor.webapp.extensions.BeforeBackgroundJobExecute; import org.apache.log4j.Logger; import javax.annotation.Nonnull; import java.util.List; import java.util.UUID; import java.util.concurrent.Callable; import java.util.concurrent.Future; } public static class ResultUrl { private final String href; private final String text; private final String target; public ResultUrl(final String href, final String text, final String target) { this.href = href; this.text = text; this.target = target; } public String getHref() { return href; } public String getTarget() { return target; } public String getText() { return text; } } protected abstract List<BeforeBackgroundJobExecute> getBeforeBackgroundJobExecutes();
protected abstract List<AfterBackgroundJobExecute> getAfterBackgroundJobExecutes();
indeedeng/proctor-webapp-library
src/main/java/com/indeed/proctor/webapp/tags/RenderEditPageInjectionTemplatesTagHandler.java
// Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/EditPageRenderer.java // public interface EditPageRenderer { // enum EditPagePosition { // TOP_FORM, // MIDDLE_FORM, // BOTTOM_FORM, // SCRIPT, // SPECIAL_CONSTANTS // } // // EditPagePosition getEditPagePosition(); // // @Deprecated // default String getRenderedHtml(final String testName, final String testDefinitionJson, final boolean isCreate){ // return ""; // } // // default String getRenderedHtml(final PageContext pageContext, final String testName, final String testDefinitionJson, final boolean isCreate){ // return ""; // } // } // // Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/EditPageRenderer.java // enum EditPagePosition { // TOP_FORM, // MIDDLE_FORM, // BOTTOM_FORM, // SCRIPT, // SPECIAL_CONSTANTS // }
import com.indeed.proctor.webapp.extensions.renderer.EditPageRenderer; import com.indeed.proctor.webapp.extensions.renderer.EditPageRenderer.EditPagePosition; import org.apache.log4j.Logger; import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; import javax.servlet.ServletContext; import javax.servlet.jsp.tagext.TagSupport; import java.io.IOException; import java.util.Map;
package com.indeed.proctor.webapp.tags; /** */ public class RenderEditPageInjectionTemplatesTagHandler extends TagSupport { private static final Logger LOGGER = Logger.getLogger(RenderEditPageInjectionTemplatesTagHandler.class);
// Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/EditPageRenderer.java // public interface EditPageRenderer { // enum EditPagePosition { // TOP_FORM, // MIDDLE_FORM, // BOTTOM_FORM, // SCRIPT, // SPECIAL_CONSTANTS // } // // EditPagePosition getEditPagePosition(); // // @Deprecated // default String getRenderedHtml(final String testName, final String testDefinitionJson, final boolean isCreate){ // return ""; // } // // default String getRenderedHtml(final PageContext pageContext, final String testName, final String testDefinitionJson, final boolean isCreate){ // return ""; // } // } // // Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/EditPageRenderer.java // enum EditPagePosition { // TOP_FORM, // MIDDLE_FORM, // BOTTOM_FORM, // SCRIPT, // SPECIAL_CONSTANTS // } // Path: src/main/java/com/indeed/proctor/webapp/tags/RenderEditPageInjectionTemplatesTagHandler.java import com.indeed.proctor.webapp.extensions.renderer.EditPageRenderer; import com.indeed.proctor.webapp.extensions.renderer.EditPageRenderer.EditPagePosition; import org.apache.log4j.Logger; import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; import javax.servlet.ServletContext; import javax.servlet.jsp.tagext.TagSupport; import java.io.IOException; import java.util.Map; package com.indeed.proctor.webapp.tags; /** */ public class RenderEditPageInjectionTemplatesTagHandler extends TagSupport { private static final Logger LOGGER = Logger.getLogger(RenderEditPageInjectionTemplatesTagHandler.class);
private EditPagePosition position;
indeedeng/proctor-webapp-library
src/main/java/com/indeed/proctor/webapp/tags/RenderEditPageInjectionTemplatesTagHandler.java
// Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/EditPageRenderer.java // public interface EditPageRenderer { // enum EditPagePosition { // TOP_FORM, // MIDDLE_FORM, // BOTTOM_FORM, // SCRIPT, // SPECIAL_CONSTANTS // } // // EditPagePosition getEditPagePosition(); // // @Deprecated // default String getRenderedHtml(final String testName, final String testDefinitionJson, final boolean isCreate){ // return ""; // } // // default String getRenderedHtml(final PageContext pageContext, final String testName, final String testDefinitionJson, final boolean isCreate){ // return ""; // } // } // // Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/EditPageRenderer.java // enum EditPagePosition { // TOP_FORM, // MIDDLE_FORM, // BOTTOM_FORM, // SCRIPT, // SPECIAL_CONSTANTS // }
import com.indeed.proctor.webapp.extensions.renderer.EditPageRenderer; import com.indeed.proctor.webapp.extensions.renderer.EditPageRenderer.EditPagePosition; import org.apache.log4j.Logger; import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; import javax.servlet.ServletContext; import javax.servlet.jsp.tagext.TagSupport; import java.io.IOException; import java.util.Map;
this.position = position; } public void setTestName(final String testName) { this.testName = testName; } public void setTestDefinitionJson(final String testDefinitionJson) { this.testDefinitionJson = testDefinitionJson; } public void setIsCreate(final boolean isCreate) { this.isCreate = isCreate; } public int doStartTag() { try { pageContext.getOut().print(renderTemplates()); } catch (IOException e) { LOGGER.error("Failed to write rendered html to page context", e); } return SKIP_BODY; } private String renderTemplates() { final StringBuilder renderedHTML = new StringBuilder(); final ServletContext servletContext = pageContext.getServletContext(); final WebApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext); try {
// Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/EditPageRenderer.java // public interface EditPageRenderer { // enum EditPagePosition { // TOP_FORM, // MIDDLE_FORM, // BOTTOM_FORM, // SCRIPT, // SPECIAL_CONSTANTS // } // // EditPagePosition getEditPagePosition(); // // @Deprecated // default String getRenderedHtml(final String testName, final String testDefinitionJson, final boolean isCreate){ // return ""; // } // // default String getRenderedHtml(final PageContext pageContext, final String testName, final String testDefinitionJson, final boolean isCreate){ // return ""; // } // } // // Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/EditPageRenderer.java // enum EditPagePosition { // TOP_FORM, // MIDDLE_FORM, // BOTTOM_FORM, // SCRIPT, // SPECIAL_CONSTANTS // } // Path: src/main/java/com/indeed/proctor/webapp/tags/RenderEditPageInjectionTemplatesTagHandler.java import com.indeed.proctor.webapp.extensions.renderer.EditPageRenderer; import com.indeed.proctor.webapp.extensions.renderer.EditPageRenderer.EditPagePosition; import org.apache.log4j.Logger; import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; import javax.servlet.ServletContext; import javax.servlet.jsp.tagext.TagSupport; import java.io.IOException; import java.util.Map; this.position = position; } public void setTestName(final String testName) { this.testName = testName; } public void setTestDefinitionJson(final String testDefinitionJson) { this.testDefinitionJson = testDefinitionJson; } public void setIsCreate(final boolean isCreate) { this.isCreate = isCreate; } public int doStartTag() { try { pageContext.getOut().print(renderTemplates()); } catch (IOException e) { LOGGER.error("Failed to write rendered html to page context", e); } return SKIP_BODY; } private String renderTemplates() { final StringBuilder renderedHTML = new StringBuilder(); final ServletContext servletContext = pageContext.getServletContext(); final WebApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext); try {
final Map<String, EditPageRenderer> rendererBeans = BeanFactoryUtils.beansOfTypeIncludingAncestors(context, EditPageRenderer.class);
indeedeng/proctor-webapp-library
src/main/java/com/indeed/proctor/webapp/extensions/DefinitionChangeLog.java
// Path: src/main/java/com/indeed/proctor/webapp/jobs/BackgroundJob.java // public static class ResultUrl { // private final String href; // private final String text; // private final String target; // // public ResultUrl(final String href, // final String text, // final String target) { // this.href = href; // this.text = text; // this.target = target; // } // // public String getHref() { // return href; // } // // public String getTarget() { // return target; // } // // public String getText() { // return text; // } // }
import com.indeed.proctor.webapp.jobs.BackgroundJob.ResultUrl; import java.util.ArrayList; import java.util.List;
package com.indeed.proctor.webapp.extensions; /** */ public class DefinitionChangeLog { private final List<String> log = new ArrayList<String>(); private final List<Error> errors = new ArrayList<Error>();
// Path: src/main/java/com/indeed/proctor/webapp/jobs/BackgroundJob.java // public static class ResultUrl { // private final String href; // private final String text; // private final String target; // // public ResultUrl(final String href, // final String text, // final String target) { // this.href = href; // this.text = text; // this.target = target; // } // // public String getHref() { // return href; // } // // public String getTarget() { // return target; // } // // public String getText() { // return text; // } // } // Path: src/main/java/com/indeed/proctor/webapp/extensions/DefinitionChangeLog.java import com.indeed.proctor.webapp.jobs.BackgroundJob.ResultUrl; import java.util.ArrayList; import java.util.List; package com.indeed.proctor.webapp.extensions; /** */ public class DefinitionChangeLog { private final List<String> log = new ArrayList<String>(); private final List<Error> errors = new ArrayList<Error>();
private final List<ResultUrl> urls = new ArrayList<ResultUrl>();
indeedeng/proctor-webapp-library
src/main/java/com/indeed/proctor/common/EnvironmentVersion.java
// Path: src/main/java/com/indeed/proctor/webapp/db/Environment.java // public enum Environment { // WORKING("trunk", 0), // QA("qa", 1), // PRODUCTION("production", 2); // // private final String name; // private final int precedence; // private Environment(final String name, final int precedence) { // this.name = name; // this.precedence = precedence; // } // // public String getName() { // return name; // } // // public int getPrecedence() { // return precedence; // } // // private static final Map<String, Environment> LOOKUP = Maps.uniqueIndex(ImmutableList.copyOf(Environment.values()), Functions.toStringFunction()); // public static Environment fromName(String name) { // if(name == null) { // return null; // } else { // return LOOKUP.get(name.toLowerCase()); // } // } // // @Override // public String toString() { // return this.getName(); // } // }
import com.indeed.proctor.store.Revision; import com.indeed.proctor.webapp.db.Environment; import java.util.Date;
this.qa = qa; this.qaEffectiveRevision = qaEffectiveRevision; this.production = production; this.productionEffectiveRevision = productionEffectiveRevision; } public EnvironmentVersion(final String testName, final Revision trunk, final Revision qa, final String qaEffectiveRevision, final Revision production, final String productionEffectiveRevision) { this(testName, trunk, trunk.getRevision(), qa, qaEffectiveRevision, production, productionEffectiveRevision); } /** * Creates a new EnvironmentVersion modifying the appropriate version and * effectiveRevision. * * @param branch * @param version * @param effectiveRevision * @return */
// Path: src/main/java/com/indeed/proctor/webapp/db/Environment.java // public enum Environment { // WORKING("trunk", 0), // QA("qa", 1), // PRODUCTION("production", 2); // // private final String name; // private final int precedence; // private Environment(final String name, final int precedence) { // this.name = name; // this.precedence = precedence; // } // // public String getName() { // return name; // } // // public int getPrecedence() { // return precedence; // } // // private static final Map<String, Environment> LOOKUP = Maps.uniqueIndex(ImmutableList.copyOf(Environment.values()), Functions.toStringFunction()); // public static Environment fromName(String name) { // if(name == null) { // return null; // } else { // return LOOKUP.get(name.toLowerCase()); // } // } // // @Override // public String toString() { // return this.getName(); // } // } // Path: src/main/java/com/indeed/proctor/common/EnvironmentVersion.java import com.indeed.proctor.store.Revision; import com.indeed.proctor.webapp.db.Environment; import java.util.Date; this.qa = qa; this.qaEffectiveRevision = qaEffectiveRevision; this.production = production; this.productionEffectiveRevision = productionEffectiveRevision; } public EnvironmentVersion(final String testName, final Revision trunk, final Revision qa, final String qaEffectiveRevision, final Revision production, final String productionEffectiveRevision) { this(testName, trunk, trunk.getRevision(), qa, qaEffectiveRevision, production, productionEffectiveRevision); } /** * Creates a new EnvironmentVersion modifying the appropriate version and * effectiveRevision. * * @param branch * @param version * @param effectiveRevision * @return */
public EnvironmentVersion update(final Environment branch, final Revision version, final String effectiveRevision ) {
indeedeng/proctor-webapp-library
src/main/java/com/indeed/proctor/webapp/DefaultClientSource.java
// Path: src/main/java/com/indeed/proctor/webapp/db/Environment.java // public enum Environment { // WORKING("trunk", 0), // QA("qa", 1), // PRODUCTION("production", 2); // // private final String name; // private final int precedence; // private Environment(final String name, final int precedence) { // this.name = name; // this.precedence = precedence; // } // // public String getName() { // return name; // } // // public int getPrecedence() { // return precedence; // } // // private static final Map<String, Environment> LOOKUP = Maps.uniqueIndex(ImmutableList.copyOf(Environment.values()), Functions.toStringFunction()); // public static Environment fromName(String name) { // if(name == null) { // return null; // } else { // return LOOKUP.get(name.toLowerCase()); // } // } // // @Override // public String toString() { // return this.getName(); // } // } // // Path: src/main/java/com/indeed/proctor/webapp/model/ProctorClientApplication.java // public class ProctorClientApplication { // private final String application; // private final String baseApplicationUrl; // private final String address; // private final Date lastUpdate; // private final String version; // // public ProctorClientApplication(final String application, // final String baseApplicationUrl, // final String address, // final Date lastUpdate, // final String version) { // this.application = application; // this.baseApplicationUrl = baseApplicationUrl; // this.address = address; // this.lastUpdate = lastUpdate; // this.version = version; // } // // public String getApplication() { // return application; // } // // public String getBaseApplicationUrl() { // return baseApplicationUrl; // } // // public String getAddress() { // return address; // } // // public Date getLastUpdate() { // return lastUpdate; // } // // public String getVersion() { // return version; // } // // @Override // public int hashCode() { // int result = 1; // result = 31 * result + address.hashCode(); // result = 31 * result + application.hashCode(); // result = 31 * result + baseApplicationUrl.hashCode(); // result = 31 * result + version.hashCode(); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null) { // return false; // } // if (getClass() != obj.getClass()) { // return false; // } // final ProctorClientApplication that = (ProctorClientApplication) obj; // return address.equals(that.address) // && application.equals(that.application) // && baseApplicationUrl.equals(that.baseApplicationUrl) // && (version.equals(that.version)); // } // // @Override // public String toString() { // return baseApplicationUrl + " @ r" + version; // } // }
import com.indeed.proctor.webapp.db.Environment; import com.indeed.proctor.webapp.model.ProctorClientApplication; import java.util.Collections; import java.util.List;
package com.indeed.proctor.webapp; /** */ public class DefaultClientSource implements ProctorClientSource { @Override
// Path: src/main/java/com/indeed/proctor/webapp/db/Environment.java // public enum Environment { // WORKING("trunk", 0), // QA("qa", 1), // PRODUCTION("production", 2); // // private final String name; // private final int precedence; // private Environment(final String name, final int precedence) { // this.name = name; // this.precedence = precedence; // } // // public String getName() { // return name; // } // // public int getPrecedence() { // return precedence; // } // // private static final Map<String, Environment> LOOKUP = Maps.uniqueIndex(ImmutableList.copyOf(Environment.values()), Functions.toStringFunction()); // public static Environment fromName(String name) { // if(name == null) { // return null; // } else { // return LOOKUP.get(name.toLowerCase()); // } // } // // @Override // public String toString() { // return this.getName(); // } // } // // Path: src/main/java/com/indeed/proctor/webapp/model/ProctorClientApplication.java // public class ProctorClientApplication { // private final String application; // private final String baseApplicationUrl; // private final String address; // private final Date lastUpdate; // private final String version; // // public ProctorClientApplication(final String application, // final String baseApplicationUrl, // final String address, // final Date lastUpdate, // final String version) { // this.application = application; // this.baseApplicationUrl = baseApplicationUrl; // this.address = address; // this.lastUpdate = lastUpdate; // this.version = version; // } // // public String getApplication() { // return application; // } // // public String getBaseApplicationUrl() { // return baseApplicationUrl; // } // // public String getAddress() { // return address; // } // // public Date getLastUpdate() { // return lastUpdate; // } // // public String getVersion() { // return version; // } // // @Override // public int hashCode() { // int result = 1; // result = 31 * result + address.hashCode(); // result = 31 * result + application.hashCode(); // result = 31 * result + baseApplicationUrl.hashCode(); // result = 31 * result + version.hashCode(); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null) { // return false; // } // if (getClass() != obj.getClass()) { // return false; // } // final ProctorClientApplication that = (ProctorClientApplication) obj; // return address.equals(that.address) // && application.equals(that.application) // && baseApplicationUrl.equals(that.baseApplicationUrl) // && (version.equals(that.version)); // } // // @Override // public String toString() { // return baseApplicationUrl + " @ r" + version; // } // } // Path: src/main/java/com/indeed/proctor/webapp/DefaultClientSource.java import com.indeed.proctor.webapp.db.Environment; import com.indeed.proctor.webapp.model.ProctorClientApplication; import java.util.Collections; import java.util.List; package com.indeed.proctor.webapp; /** */ public class DefaultClientSource implements ProctorClientSource { @Override
public List<ProctorClientApplication> loadClients(final Environment environment) {
indeedeng/proctor-webapp-library
src/main/java/com/indeed/proctor/webapp/DefaultClientSource.java
// Path: src/main/java/com/indeed/proctor/webapp/db/Environment.java // public enum Environment { // WORKING("trunk", 0), // QA("qa", 1), // PRODUCTION("production", 2); // // private final String name; // private final int precedence; // private Environment(final String name, final int precedence) { // this.name = name; // this.precedence = precedence; // } // // public String getName() { // return name; // } // // public int getPrecedence() { // return precedence; // } // // private static final Map<String, Environment> LOOKUP = Maps.uniqueIndex(ImmutableList.copyOf(Environment.values()), Functions.toStringFunction()); // public static Environment fromName(String name) { // if(name == null) { // return null; // } else { // return LOOKUP.get(name.toLowerCase()); // } // } // // @Override // public String toString() { // return this.getName(); // } // } // // Path: src/main/java/com/indeed/proctor/webapp/model/ProctorClientApplication.java // public class ProctorClientApplication { // private final String application; // private final String baseApplicationUrl; // private final String address; // private final Date lastUpdate; // private final String version; // // public ProctorClientApplication(final String application, // final String baseApplicationUrl, // final String address, // final Date lastUpdate, // final String version) { // this.application = application; // this.baseApplicationUrl = baseApplicationUrl; // this.address = address; // this.lastUpdate = lastUpdate; // this.version = version; // } // // public String getApplication() { // return application; // } // // public String getBaseApplicationUrl() { // return baseApplicationUrl; // } // // public String getAddress() { // return address; // } // // public Date getLastUpdate() { // return lastUpdate; // } // // public String getVersion() { // return version; // } // // @Override // public int hashCode() { // int result = 1; // result = 31 * result + address.hashCode(); // result = 31 * result + application.hashCode(); // result = 31 * result + baseApplicationUrl.hashCode(); // result = 31 * result + version.hashCode(); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null) { // return false; // } // if (getClass() != obj.getClass()) { // return false; // } // final ProctorClientApplication that = (ProctorClientApplication) obj; // return address.equals(that.address) // && application.equals(that.application) // && baseApplicationUrl.equals(that.baseApplicationUrl) // && (version.equals(that.version)); // } // // @Override // public String toString() { // return baseApplicationUrl + " @ r" + version; // } // }
import com.indeed.proctor.webapp.db.Environment; import com.indeed.proctor.webapp.model.ProctorClientApplication; import java.util.Collections; import java.util.List;
package com.indeed.proctor.webapp; /** */ public class DefaultClientSource implements ProctorClientSource { @Override
// Path: src/main/java/com/indeed/proctor/webapp/db/Environment.java // public enum Environment { // WORKING("trunk", 0), // QA("qa", 1), // PRODUCTION("production", 2); // // private final String name; // private final int precedence; // private Environment(final String name, final int precedence) { // this.name = name; // this.precedence = precedence; // } // // public String getName() { // return name; // } // // public int getPrecedence() { // return precedence; // } // // private static final Map<String, Environment> LOOKUP = Maps.uniqueIndex(ImmutableList.copyOf(Environment.values()), Functions.toStringFunction()); // public static Environment fromName(String name) { // if(name == null) { // return null; // } else { // return LOOKUP.get(name.toLowerCase()); // } // } // // @Override // public String toString() { // return this.getName(); // } // } // // Path: src/main/java/com/indeed/proctor/webapp/model/ProctorClientApplication.java // public class ProctorClientApplication { // private final String application; // private final String baseApplicationUrl; // private final String address; // private final Date lastUpdate; // private final String version; // // public ProctorClientApplication(final String application, // final String baseApplicationUrl, // final String address, // final Date lastUpdate, // final String version) { // this.application = application; // this.baseApplicationUrl = baseApplicationUrl; // this.address = address; // this.lastUpdate = lastUpdate; // this.version = version; // } // // public String getApplication() { // return application; // } // // public String getBaseApplicationUrl() { // return baseApplicationUrl; // } // // public String getAddress() { // return address; // } // // public Date getLastUpdate() { // return lastUpdate; // } // // public String getVersion() { // return version; // } // // @Override // public int hashCode() { // int result = 1; // result = 31 * result + address.hashCode(); // result = 31 * result + application.hashCode(); // result = 31 * result + baseApplicationUrl.hashCode(); // result = 31 * result + version.hashCode(); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) { // return true; // } // if (obj == null) { // return false; // } // if (getClass() != obj.getClass()) { // return false; // } // final ProctorClientApplication that = (ProctorClientApplication) obj; // return address.equals(that.address) // && application.equals(that.application) // && baseApplicationUrl.equals(that.baseApplicationUrl) // && (version.equals(that.version)); // } // // @Override // public String toString() { // return baseApplicationUrl + " @ r" + version; // } // } // Path: src/main/java/com/indeed/proctor/webapp/DefaultClientSource.java import com.indeed.proctor.webapp.db.Environment; import com.indeed.proctor.webapp.model.ProctorClientApplication; import java.util.Collections; import java.util.List; package com.indeed.proctor.webapp; /** */ public class DefaultClientSource implements ProctorClientSource { @Override
public List<ProctorClientApplication> loadClients(final Environment environment) {
indeedeng/proctor-webapp-library
src/main/java/com/indeed/proctor/webapp/controllers/TestMatrixApiController.java
// Path: src/main/java/com/indeed/proctor/webapp/db/Environment.java // public enum Environment { // WORKING("trunk", 0), // QA("qa", 1), // PRODUCTION("production", 2); // // private final String name; // private final int precedence; // private Environment(final String name, final int precedence) { // this.name = name; // this.precedence = precedence; // } // // public String getName() { // return name; // } // // public int getPrecedence() { // return precedence; // } // // private static final Map<String, Environment> LOOKUP = Maps.uniqueIndex(ImmutableList.copyOf(Environment.values()), Functions.toStringFunction()); // public static Environment fromName(String name) { // if(name == null) { // return null; // } else { // return LOOKUP.get(name.toLowerCase()); // } // } // // @Override // public String toString() { // return this.getName(); // } // } // // Path: src/main/java/com/indeed/proctor/webapp/model/WebappConfiguration.java // @Component // public class WebappConfiguration { // private final boolean useCompiledCSS; // private final boolean useCompiledJavaScript; // private final int verifyHttpTimeout; // private final int verifyExecutorThreads; // // @SuppressWarnings({"SpringJavaAutowiringInspection"}) // @Autowired // public WebappConfiguration(@Value("${use.compiled.css:true}") boolean useCompiledCSS, // @Value("${use.compiled.javascript:true}") boolean useCompiledJavaScript, // @Value("${verify.http.timeout:1000}") int verifyHttpTimeout, // @Value("${verify.executor.threads:10}") int verifyExecutorThreads) { // this.useCompiledCSS = useCompiledCSS; // this.useCompiledJavaScript = useCompiledJavaScript; // this.verifyHttpTimeout = verifyHttpTimeout; // this.verifyExecutorThreads = verifyExecutorThreads; // Preconditions.checkArgument(verifyHttpTimeout > 0, "verifyHttpTimeout > 0"); // Preconditions.checkArgument(verifyExecutorThreads > 0, "verifyExecutorThreads > 0"); // } // // public boolean isUseCompiledCSS() { // return useCompiledCSS; // } // // public boolean isUseCompiledJavaScript() { // return useCompiledJavaScript; // } // // public int getVerifyHttpTimeout() { // return verifyHttpTimeout; // } // // public int getVerifyExecutorThreads() { // return verifyExecutorThreads; // } // } // // Path: src/main/java/com/indeed/proctor/webapp/views/JsonView.java // public class JsonView implements View { // // private static final String CONTENT_TYPE = "application/json;charset=utf-8"; // // private static final ObjectWriter JSON_WRITER = Serializers.strict().writerWithDefaultPrettyPrinter(); // private final Object data; // // public JsonView(Object data) { // this.data = data; // } // // @Override // public String getContentType() { // return CONTENT_TYPE; // } // // @Override // public void render(Map<String, ?> model, // HttpServletRequest request, // HttpServletResponse response) throws Exception { // response.setHeader("Content-Type", CONTENT_TYPE); // JSON_WRITER.writeValue(response.getWriter(), data); // } // }
import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap; import com.indeed.proctor.common.model.TestDefinition; import com.indeed.proctor.common.model.TestMatrixVersion; import com.indeed.proctor.store.ProctorStore; import com.indeed.proctor.store.Revision; import com.indeed.proctor.store.StoreException; import com.indeed.proctor.webapp.db.Environment; import com.indeed.proctor.webapp.model.WebappConfiguration; import com.indeed.proctor.webapp.views.JsonView; import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.servlet.View; import java.util.List;
package com.indeed.proctor.webapp.controllers; @Controller @RequestMapping({"/api/v1", "/proctor/api/v1"}) public class TestMatrixApiController extends AbstractController { private static final Logger LOGGER = Logger.getLogger(TestMatrixApiController.class); @Autowired
// Path: src/main/java/com/indeed/proctor/webapp/db/Environment.java // public enum Environment { // WORKING("trunk", 0), // QA("qa", 1), // PRODUCTION("production", 2); // // private final String name; // private final int precedence; // private Environment(final String name, final int precedence) { // this.name = name; // this.precedence = precedence; // } // // public String getName() { // return name; // } // // public int getPrecedence() { // return precedence; // } // // private static final Map<String, Environment> LOOKUP = Maps.uniqueIndex(ImmutableList.copyOf(Environment.values()), Functions.toStringFunction()); // public static Environment fromName(String name) { // if(name == null) { // return null; // } else { // return LOOKUP.get(name.toLowerCase()); // } // } // // @Override // public String toString() { // return this.getName(); // } // } // // Path: src/main/java/com/indeed/proctor/webapp/model/WebappConfiguration.java // @Component // public class WebappConfiguration { // private final boolean useCompiledCSS; // private final boolean useCompiledJavaScript; // private final int verifyHttpTimeout; // private final int verifyExecutorThreads; // // @SuppressWarnings({"SpringJavaAutowiringInspection"}) // @Autowired // public WebappConfiguration(@Value("${use.compiled.css:true}") boolean useCompiledCSS, // @Value("${use.compiled.javascript:true}") boolean useCompiledJavaScript, // @Value("${verify.http.timeout:1000}") int verifyHttpTimeout, // @Value("${verify.executor.threads:10}") int verifyExecutorThreads) { // this.useCompiledCSS = useCompiledCSS; // this.useCompiledJavaScript = useCompiledJavaScript; // this.verifyHttpTimeout = verifyHttpTimeout; // this.verifyExecutorThreads = verifyExecutorThreads; // Preconditions.checkArgument(verifyHttpTimeout > 0, "verifyHttpTimeout > 0"); // Preconditions.checkArgument(verifyExecutorThreads > 0, "verifyExecutorThreads > 0"); // } // // public boolean isUseCompiledCSS() { // return useCompiledCSS; // } // // public boolean isUseCompiledJavaScript() { // return useCompiledJavaScript; // } // // public int getVerifyHttpTimeout() { // return verifyHttpTimeout; // } // // public int getVerifyExecutorThreads() { // return verifyExecutorThreads; // } // } // // Path: src/main/java/com/indeed/proctor/webapp/views/JsonView.java // public class JsonView implements View { // // private static final String CONTENT_TYPE = "application/json;charset=utf-8"; // // private static final ObjectWriter JSON_WRITER = Serializers.strict().writerWithDefaultPrettyPrinter(); // private final Object data; // // public JsonView(Object data) { // this.data = data; // } // // @Override // public String getContentType() { // return CONTENT_TYPE; // } // // @Override // public void render(Map<String, ?> model, // HttpServletRequest request, // HttpServletResponse response) throws Exception { // response.setHeader("Content-Type", CONTENT_TYPE); // JSON_WRITER.writeValue(response.getWriter(), data); // } // } // Path: src/main/java/com/indeed/proctor/webapp/controllers/TestMatrixApiController.java import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap; import com.indeed.proctor.common.model.TestDefinition; import com.indeed.proctor.common.model.TestMatrixVersion; import com.indeed.proctor.store.ProctorStore; import com.indeed.proctor.store.Revision; import com.indeed.proctor.store.StoreException; import com.indeed.proctor.webapp.db.Environment; import com.indeed.proctor.webapp.model.WebappConfiguration; import com.indeed.proctor.webapp.views.JsonView; import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.servlet.View; import java.util.List; package com.indeed.proctor.webapp.controllers; @Controller @RequestMapping({"/api/v1", "/proctor/api/v1"}) public class TestMatrixApiController extends AbstractController { private static final Logger LOGGER = Logger.getLogger(TestMatrixApiController.class); @Autowired
public TestMatrixApiController(final WebappConfiguration configuration,
indeedeng/proctor-webapp-library
src/main/java/com/indeed/proctor/webapp/controllers/TestMatrixApiController.java
// Path: src/main/java/com/indeed/proctor/webapp/db/Environment.java // public enum Environment { // WORKING("trunk", 0), // QA("qa", 1), // PRODUCTION("production", 2); // // private final String name; // private final int precedence; // private Environment(final String name, final int precedence) { // this.name = name; // this.precedence = precedence; // } // // public String getName() { // return name; // } // // public int getPrecedence() { // return precedence; // } // // private static final Map<String, Environment> LOOKUP = Maps.uniqueIndex(ImmutableList.copyOf(Environment.values()), Functions.toStringFunction()); // public static Environment fromName(String name) { // if(name == null) { // return null; // } else { // return LOOKUP.get(name.toLowerCase()); // } // } // // @Override // public String toString() { // return this.getName(); // } // } // // Path: src/main/java/com/indeed/proctor/webapp/model/WebappConfiguration.java // @Component // public class WebappConfiguration { // private final boolean useCompiledCSS; // private final boolean useCompiledJavaScript; // private final int verifyHttpTimeout; // private final int verifyExecutorThreads; // // @SuppressWarnings({"SpringJavaAutowiringInspection"}) // @Autowired // public WebappConfiguration(@Value("${use.compiled.css:true}") boolean useCompiledCSS, // @Value("${use.compiled.javascript:true}") boolean useCompiledJavaScript, // @Value("${verify.http.timeout:1000}") int verifyHttpTimeout, // @Value("${verify.executor.threads:10}") int verifyExecutorThreads) { // this.useCompiledCSS = useCompiledCSS; // this.useCompiledJavaScript = useCompiledJavaScript; // this.verifyHttpTimeout = verifyHttpTimeout; // this.verifyExecutorThreads = verifyExecutorThreads; // Preconditions.checkArgument(verifyHttpTimeout > 0, "verifyHttpTimeout > 0"); // Preconditions.checkArgument(verifyExecutorThreads > 0, "verifyExecutorThreads > 0"); // } // // public boolean isUseCompiledCSS() { // return useCompiledCSS; // } // // public boolean isUseCompiledJavaScript() { // return useCompiledJavaScript; // } // // public int getVerifyHttpTimeout() { // return verifyHttpTimeout; // } // // public int getVerifyExecutorThreads() { // return verifyExecutorThreads; // } // } // // Path: src/main/java/com/indeed/proctor/webapp/views/JsonView.java // public class JsonView implements View { // // private static final String CONTENT_TYPE = "application/json;charset=utf-8"; // // private static final ObjectWriter JSON_WRITER = Serializers.strict().writerWithDefaultPrettyPrinter(); // private final Object data; // // public JsonView(Object data) { // this.data = data; // } // // @Override // public String getContentType() { // return CONTENT_TYPE; // } // // @Override // public void render(Map<String, ?> model, // HttpServletRequest request, // HttpServletResponse response) throws Exception { // response.setHeader("Content-Type", CONTENT_TYPE); // JSON_WRITER.writeValue(response.getWriter(), data); // } // }
import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap; import com.indeed.proctor.common.model.TestDefinition; import com.indeed.proctor.common.model.TestMatrixVersion; import com.indeed.proctor.store.ProctorStore; import com.indeed.proctor.store.Revision; import com.indeed.proctor.store.StoreException; import com.indeed.proctor.webapp.db.Environment; import com.indeed.proctor.webapp.model.WebappConfiguration; import com.indeed.proctor.webapp.views.JsonView; import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.servlet.View; import java.util.List;
package com.indeed.proctor.webapp.controllers; @Controller @RequestMapping({"/api/v1", "/proctor/api/v1"}) public class TestMatrixApiController extends AbstractController { private static final Logger LOGGER = Logger.getLogger(TestMatrixApiController.class); @Autowired public TestMatrixApiController(final WebappConfiguration configuration, @Qualifier("trunk") final ProctorStore trunkStore, @Qualifier("qa") final ProctorStore qaStore, @Qualifier("production") final ProctorStore productionStore) { super(configuration, trunkStore, qaStore, productionStore); } @RequestMapping(value = "/{branchOrRevision}/matrix", method = RequestMethod.GET)
// Path: src/main/java/com/indeed/proctor/webapp/db/Environment.java // public enum Environment { // WORKING("trunk", 0), // QA("qa", 1), // PRODUCTION("production", 2); // // private final String name; // private final int precedence; // private Environment(final String name, final int precedence) { // this.name = name; // this.precedence = precedence; // } // // public String getName() { // return name; // } // // public int getPrecedence() { // return precedence; // } // // private static final Map<String, Environment> LOOKUP = Maps.uniqueIndex(ImmutableList.copyOf(Environment.values()), Functions.toStringFunction()); // public static Environment fromName(String name) { // if(name == null) { // return null; // } else { // return LOOKUP.get(name.toLowerCase()); // } // } // // @Override // public String toString() { // return this.getName(); // } // } // // Path: src/main/java/com/indeed/proctor/webapp/model/WebappConfiguration.java // @Component // public class WebappConfiguration { // private final boolean useCompiledCSS; // private final boolean useCompiledJavaScript; // private final int verifyHttpTimeout; // private final int verifyExecutorThreads; // // @SuppressWarnings({"SpringJavaAutowiringInspection"}) // @Autowired // public WebappConfiguration(@Value("${use.compiled.css:true}") boolean useCompiledCSS, // @Value("${use.compiled.javascript:true}") boolean useCompiledJavaScript, // @Value("${verify.http.timeout:1000}") int verifyHttpTimeout, // @Value("${verify.executor.threads:10}") int verifyExecutorThreads) { // this.useCompiledCSS = useCompiledCSS; // this.useCompiledJavaScript = useCompiledJavaScript; // this.verifyHttpTimeout = verifyHttpTimeout; // this.verifyExecutorThreads = verifyExecutorThreads; // Preconditions.checkArgument(verifyHttpTimeout > 0, "verifyHttpTimeout > 0"); // Preconditions.checkArgument(verifyExecutorThreads > 0, "verifyExecutorThreads > 0"); // } // // public boolean isUseCompiledCSS() { // return useCompiledCSS; // } // // public boolean isUseCompiledJavaScript() { // return useCompiledJavaScript; // } // // public int getVerifyHttpTimeout() { // return verifyHttpTimeout; // } // // public int getVerifyExecutorThreads() { // return verifyExecutorThreads; // } // } // // Path: src/main/java/com/indeed/proctor/webapp/views/JsonView.java // public class JsonView implements View { // // private static final String CONTENT_TYPE = "application/json;charset=utf-8"; // // private static final ObjectWriter JSON_WRITER = Serializers.strict().writerWithDefaultPrettyPrinter(); // private final Object data; // // public JsonView(Object data) { // this.data = data; // } // // @Override // public String getContentType() { // return CONTENT_TYPE; // } // // @Override // public void render(Map<String, ?> model, // HttpServletRequest request, // HttpServletResponse response) throws Exception { // response.setHeader("Content-Type", CONTENT_TYPE); // JSON_WRITER.writeValue(response.getWriter(), data); // } // } // Path: src/main/java/com/indeed/proctor/webapp/controllers/TestMatrixApiController.java import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap; import com.indeed.proctor.common.model.TestDefinition; import com.indeed.proctor.common.model.TestMatrixVersion; import com.indeed.proctor.store.ProctorStore; import com.indeed.proctor.store.Revision; import com.indeed.proctor.store.StoreException; import com.indeed.proctor.webapp.db.Environment; import com.indeed.proctor.webapp.model.WebappConfiguration; import com.indeed.proctor.webapp.views.JsonView; import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.servlet.View; import java.util.List; package com.indeed.proctor.webapp.controllers; @Controller @RequestMapping({"/api/v1", "/proctor/api/v1"}) public class TestMatrixApiController extends AbstractController { private static final Logger LOGGER = Logger.getLogger(TestMatrixApiController.class); @Autowired public TestMatrixApiController(final WebappConfiguration configuration, @Qualifier("trunk") final ProctorStore trunkStore, @Qualifier("qa") final ProctorStore qaStore, @Qualifier("production") final ProctorStore productionStore) { super(configuration, trunkStore, qaStore, productionStore); } @RequestMapping(value = "/{branchOrRevision}/matrix", method = RequestMethod.GET)
public JsonView getTestMatrix(
indeedeng/proctor-webapp-library
src/main/java/com/indeed/proctor/webapp/controllers/TestMatrixApiController.java
// Path: src/main/java/com/indeed/proctor/webapp/db/Environment.java // public enum Environment { // WORKING("trunk", 0), // QA("qa", 1), // PRODUCTION("production", 2); // // private final String name; // private final int precedence; // private Environment(final String name, final int precedence) { // this.name = name; // this.precedence = precedence; // } // // public String getName() { // return name; // } // // public int getPrecedence() { // return precedence; // } // // private static final Map<String, Environment> LOOKUP = Maps.uniqueIndex(ImmutableList.copyOf(Environment.values()), Functions.toStringFunction()); // public static Environment fromName(String name) { // if(name == null) { // return null; // } else { // return LOOKUP.get(name.toLowerCase()); // } // } // // @Override // public String toString() { // return this.getName(); // } // } // // Path: src/main/java/com/indeed/proctor/webapp/model/WebappConfiguration.java // @Component // public class WebappConfiguration { // private final boolean useCompiledCSS; // private final boolean useCompiledJavaScript; // private final int verifyHttpTimeout; // private final int verifyExecutorThreads; // // @SuppressWarnings({"SpringJavaAutowiringInspection"}) // @Autowired // public WebappConfiguration(@Value("${use.compiled.css:true}") boolean useCompiledCSS, // @Value("${use.compiled.javascript:true}") boolean useCompiledJavaScript, // @Value("${verify.http.timeout:1000}") int verifyHttpTimeout, // @Value("${verify.executor.threads:10}") int verifyExecutorThreads) { // this.useCompiledCSS = useCompiledCSS; // this.useCompiledJavaScript = useCompiledJavaScript; // this.verifyHttpTimeout = verifyHttpTimeout; // this.verifyExecutorThreads = verifyExecutorThreads; // Preconditions.checkArgument(verifyHttpTimeout > 0, "verifyHttpTimeout > 0"); // Preconditions.checkArgument(verifyExecutorThreads > 0, "verifyExecutorThreads > 0"); // } // // public boolean isUseCompiledCSS() { // return useCompiledCSS; // } // // public boolean isUseCompiledJavaScript() { // return useCompiledJavaScript; // } // // public int getVerifyHttpTimeout() { // return verifyHttpTimeout; // } // // public int getVerifyExecutorThreads() { // return verifyExecutorThreads; // } // } // // Path: src/main/java/com/indeed/proctor/webapp/views/JsonView.java // public class JsonView implements View { // // private static final String CONTENT_TYPE = "application/json;charset=utf-8"; // // private static final ObjectWriter JSON_WRITER = Serializers.strict().writerWithDefaultPrettyPrinter(); // private final Object data; // // public JsonView(Object data) { // this.data = data; // } // // @Override // public String getContentType() { // return CONTENT_TYPE; // } // // @Override // public void render(Map<String, ?> model, // HttpServletRequest request, // HttpServletResponse response) throws Exception { // response.setHeader("Content-Type", CONTENT_TYPE); // JSON_WRITER.writeValue(response.getWriter(), data); // } // }
import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap; import com.indeed.proctor.common.model.TestDefinition; import com.indeed.proctor.common.model.TestMatrixVersion; import com.indeed.proctor.store.ProctorStore; import com.indeed.proctor.store.Revision; import com.indeed.proctor.store.StoreException; import com.indeed.proctor.webapp.db.Environment; import com.indeed.proctor.webapp.model.WebappConfiguration; import com.indeed.proctor.webapp.views.JsonView; import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.servlet.View; import java.util.List;
package com.indeed.proctor.webapp.controllers; @Controller @RequestMapping({"/api/v1", "/proctor/api/v1"}) public class TestMatrixApiController extends AbstractController { private static final Logger LOGGER = Logger.getLogger(TestMatrixApiController.class); @Autowired public TestMatrixApiController(final WebappConfiguration configuration, @Qualifier("trunk") final ProctorStore trunkStore, @Qualifier("qa") final ProctorStore qaStore, @Qualifier("production") final ProctorStore productionStore) { super(configuration, trunkStore, qaStore, productionStore); } @RequestMapping(value = "/{branchOrRevision}/matrix", method = RequestMethod.GET) public JsonView getTestMatrix( @PathVariable final String branchOrRevision ) throws StoreException { final TestMatrixVersion testMatrixVersion = queryMatrixFromBranchOrRevision(branchOrRevision); Preconditions.checkNotNull(testMatrixVersion, String.format("Branch or revision %s not correct", branchOrRevision)); return new JsonView(testMatrixVersion); } @RequestMapping(value = "/{branch}/matrix/history", method = RequestMethod.GET) public JsonView getTestMatrixHistory( @PathVariable final String branch, @RequestParam(required = false, value = "start", defaultValue = "0") final int start, @RequestParam(required = false, value = "limit", defaultValue = "32") final int limit ) throws StoreException {
// Path: src/main/java/com/indeed/proctor/webapp/db/Environment.java // public enum Environment { // WORKING("trunk", 0), // QA("qa", 1), // PRODUCTION("production", 2); // // private final String name; // private final int precedence; // private Environment(final String name, final int precedence) { // this.name = name; // this.precedence = precedence; // } // // public String getName() { // return name; // } // // public int getPrecedence() { // return precedence; // } // // private static final Map<String, Environment> LOOKUP = Maps.uniqueIndex(ImmutableList.copyOf(Environment.values()), Functions.toStringFunction()); // public static Environment fromName(String name) { // if(name == null) { // return null; // } else { // return LOOKUP.get(name.toLowerCase()); // } // } // // @Override // public String toString() { // return this.getName(); // } // } // // Path: src/main/java/com/indeed/proctor/webapp/model/WebappConfiguration.java // @Component // public class WebappConfiguration { // private final boolean useCompiledCSS; // private final boolean useCompiledJavaScript; // private final int verifyHttpTimeout; // private final int verifyExecutorThreads; // // @SuppressWarnings({"SpringJavaAutowiringInspection"}) // @Autowired // public WebappConfiguration(@Value("${use.compiled.css:true}") boolean useCompiledCSS, // @Value("${use.compiled.javascript:true}") boolean useCompiledJavaScript, // @Value("${verify.http.timeout:1000}") int verifyHttpTimeout, // @Value("${verify.executor.threads:10}") int verifyExecutorThreads) { // this.useCompiledCSS = useCompiledCSS; // this.useCompiledJavaScript = useCompiledJavaScript; // this.verifyHttpTimeout = verifyHttpTimeout; // this.verifyExecutorThreads = verifyExecutorThreads; // Preconditions.checkArgument(verifyHttpTimeout > 0, "verifyHttpTimeout > 0"); // Preconditions.checkArgument(verifyExecutorThreads > 0, "verifyExecutorThreads > 0"); // } // // public boolean isUseCompiledCSS() { // return useCompiledCSS; // } // // public boolean isUseCompiledJavaScript() { // return useCompiledJavaScript; // } // // public int getVerifyHttpTimeout() { // return verifyHttpTimeout; // } // // public int getVerifyExecutorThreads() { // return verifyExecutorThreads; // } // } // // Path: src/main/java/com/indeed/proctor/webapp/views/JsonView.java // public class JsonView implements View { // // private static final String CONTENT_TYPE = "application/json;charset=utf-8"; // // private static final ObjectWriter JSON_WRITER = Serializers.strict().writerWithDefaultPrettyPrinter(); // private final Object data; // // public JsonView(Object data) { // this.data = data; // } // // @Override // public String getContentType() { // return CONTENT_TYPE; // } // // @Override // public void render(Map<String, ?> model, // HttpServletRequest request, // HttpServletResponse response) throws Exception { // response.setHeader("Content-Type", CONTENT_TYPE); // JSON_WRITER.writeValue(response.getWriter(), data); // } // } // Path: src/main/java/com/indeed/proctor/webapp/controllers/TestMatrixApiController.java import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap; import com.indeed.proctor.common.model.TestDefinition; import com.indeed.proctor.common.model.TestMatrixVersion; import com.indeed.proctor.store.ProctorStore; import com.indeed.proctor.store.Revision; import com.indeed.proctor.store.StoreException; import com.indeed.proctor.webapp.db.Environment; import com.indeed.proctor.webapp.model.WebappConfiguration; import com.indeed.proctor.webapp.views.JsonView; import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.servlet.View; import java.util.List; package com.indeed.proctor.webapp.controllers; @Controller @RequestMapping({"/api/v1", "/proctor/api/v1"}) public class TestMatrixApiController extends AbstractController { private static final Logger LOGGER = Logger.getLogger(TestMatrixApiController.class); @Autowired public TestMatrixApiController(final WebappConfiguration configuration, @Qualifier("trunk") final ProctorStore trunkStore, @Qualifier("qa") final ProctorStore qaStore, @Qualifier("production") final ProctorStore productionStore) { super(configuration, trunkStore, qaStore, productionStore); } @RequestMapping(value = "/{branchOrRevision}/matrix", method = RequestMethod.GET) public JsonView getTestMatrix( @PathVariable final String branchOrRevision ) throws StoreException { final TestMatrixVersion testMatrixVersion = queryMatrixFromBranchOrRevision(branchOrRevision); Preconditions.checkNotNull(testMatrixVersion, String.format("Branch or revision %s not correct", branchOrRevision)); return new JsonView(testMatrixVersion); } @RequestMapping(value = "/{branch}/matrix/history", method = RequestMethod.GET) public JsonView getTestMatrixHistory( @PathVariable final String branch, @RequestParam(required = false, value = "start", defaultValue = "0") final int start, @RequestParam(required = false, value = "limit", defaultValue = "32") final int limit ) throws StoreException {
final Environment environment = Environment.fromName(branch);
indeedeng/proctor-webapp-library
src/main/java/com/indeed/proctor/webapp/jobs/CommentFormatter.java
// Path: src/main/java/com/indeed/proctor/webapp/extensions/RevisionCommitCommentFormatter.java // public interface RevisionCommitCommentFormatter { // public String formatComment(final String comment, final Map<String, String[]> extensionFields); // }
import com.indeed.proctor.webapp.extensions.RevisionCommitCommentFormatter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.Map;
package com.indeed.proctor.webapp.jobs; @Component public class CommentFormatter {
// Path: src/main/java/com/indeed/proctor/webapp/extensions/RevisionCommitCommentFormatter.java // public interface RevisionCommitCommentFormatter { // public String formatComment(final String comment, final Map<String, String[]> extensionFields); // } // Path: src/main/java/com/indeed/proctor/webapp/jobs/CommentFormatter.java import com.indeed.proctor.webapp.extensions.RevisionCommitCommentFormatter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.Map; package com.indeed.proctor.webapp.jobs; @Component public class CommentFormatter {
private final RevisionCommitCommentFormatter revisionCommitCommentFormatter;
indeedeng/proctor-webapp-library
src/main/java/com/indeed/proctor/webapp/extensions/renderer/BasePageRenderer.java
// Path: src/main/java/com/indeed/proctor/webapp/db/Environment.java // public enum Environment { // WORKING("trunk", 0), // QA("qa", 1), // PRODUCTION("production", 2); // // private final String name; // private final int precedence; // private Environment(final String name, final int precedence) { // this.name = name; // this.precedence = precedence; // } // // public String getName() { // return name; // } // // public int getPrecedence() { // return precedence; // } // // private static final Map<String, Environment> LOOKUP = Maps.uniqueIndex(ImmutableList.copyOf(Environment.values()), Functions.toStringFunction()); // public static Environment fromName(String name) { // if(name == null) { // return null; // } else { // return LOOKUP.get(name.toLowerCase()); // } // } // // @Override // public String toString() { // return this.getName(); // } // }
import com.indeed.proctor.webapp.db.Environment; import javax.servlet.jsp.PageContext;
package com.indeed.proctor.webapp.extensions.renderer; /** */ public interface BasePageRenderer { enum BasePagePosition { HEAD, NAVBAR_BUTTON, FOOTER, } BasePagePosition getBasePagePosition(); @Deprecated
// Path: src/main/java/com/indeed/proctor/webapp/db/Environment.java // public enum Environment { // WORKING("trunk", 0), // QA("qa", 1), // PRODUCTION("production", 2); // // private final String name; // private final int precedence; // private Environment(final String name, final int precedence) { // this.name = name; // this.precedence = precedence; // } // // public String getName() { // return name; // } // // public int getPrecedence() { // return precedence; // } // // private static final Map<String, Environment> LOOKUP = Maps.uniqueIndex(ImmutableList.copyOf(Environment.values()), Functions.toStringFunction()); // public static Environment fromName(String name) { // if(name == null) { // return null; // } else { // return LOOKUP.get(name.toLowerCase()); // } // } // // @Override // public String toString() { // return this.getName(); // } // } // Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/BasePageRenderer.java import com.indeed.proctor.webapp.db.Environment; import javax.servlet.jsp.PageContext; package com.indeed.proctor.webapp.extensions.renderer; /** */ public interface BasePageRenderer { enum BasePagePosition { HEAD, NAVBAR_BUTTON, FOOTER, } BasePagePosition getBasePagePosition(); @Deprecated
default String getRenderedHtml(final Environment branch) {
indeedeng/proctor-webapp-library
src/main/java/com/indeed/proctor/webapp/tags/RenderDefinitionDeletePageInjectionTemplatesHandler.java
// Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/DefinitionDeletePageRenderer.java // public interface DefinitionDeletePageRenderer { // enum DefinitionDeletePagePosition { // TOP_FORM, // MIDDLE_FORM, // BOTTOM_FORM, // SCRIPT // } // // DefinitionDeletePagePosition getDefinitionDeletePagePosition(); // // @Deprecated // default String getRenderedHtml(final String testName){ // return ""; // } // // default String getRenderedHtml(final PageContext pageContext, final String testName){ // return ""; // } // } // // Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/DefinitionDeletePageRenderer.java // enum DefinitionDeletePagePosition { // TOP_FORM, // MIDDLE_FORM, // BOTTOM_FORM, // SCRIPT // }
import com.indeed.proctor.webapp.extensions.renderer.DefinitionDeletePageRenderer; import com.indeed.proctor.webapp.extensions.renderer.DefinitionDeletePageRenderer.DefinitionDeletePagePosition; import org.apache.log4j.Logger; import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; import javax.servlet.ServletContext; import javax.servlet.jsp.tagext.TagSupport; import java.io.IOException; import java.util.Map;
package com.indeed.proctor.webapp.tags; /** */ public class RenderDefinitionDeletePageInjectionTemplatesHandler extends TagSupport { private static final Logger LOGGER = Logger.getLogger(RenderDefinitionDeletePageInjectionTemplatesHandler.class);
// Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/DefinitionDeletePageRenderer.java // public interface DefinitionDeletePageRenderer { // enum DefinitionDeletePagePosition { // TOP_FORM, // MIDDLE_FORM, // BOTTOM_FORM, // SCRIPT // } // // DefinitionDeletePagePosition getDefinitionDeletePagePosition(); // // @Deprecated // default String getRenderedHtml(final String testName){ // return ""; // } // // default String getRenderedHtml(final PageContext pageContext, final String testName){ // return ""; // } // } // // Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/DefinitionDeletePageRenderer.java // enum DefinitionDeletePagePosition { // TOP_FORM, // MIDDLE_FORM, // BOTTOM_FORM, // SCRIPT // } // Path: src/main/java/com/indeed/proctor/webapp/tags/RenderDefinitionDeletePageInjectionTemplatesHandler.java import com.indeed.proctor.webapp.extensions.renderer.DefinitionDeletePageRenderer; import com.indeed.proctor.webapp.extensions.renderer.DefinitionDeletePageRenderer.DefinitionDeletePagePosition; import org.apache.log4j.Logger; import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; import javax.servlet.ServletContext; import javax.servlet.jsp.tagext.TagSupport; import java.io.IOException; import java.util.Map; package com.indeed.proctor.webapp.tags; /** */ public class RenderDefinitionDeletePageInjectionTemplatesHandler extends TagSupport { private static final Logger LOGGER = Logger.getLogger(RenderDefinitionDeletePageInjectionTemplatesHandler.class);
private DefinitionDeletePagePosition position;
indeedeng/proctor-webapp-library
src/main/java/com/indeed/proctor/webapp/tags/RenderDefinitionDeletePageInjectionTemplatesHandler.java
// Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/DefinitionDeletePageRenderer.java // public interface DefinitionDeletePageRenderer { // enum DefinitionDeletePagePosition { // TOP_FORM, // MIDDLE_FORM, // BOTTOM_FORM, // SCRIPT // } // // DefinitionDeletePagePosition getDefinitionDeletePagePosition(); // // @Deprecated // default String getRenderedHtml(final String testName){ // return ""; // } // // default String getRenderedHtml(final PageContext pageContext, final String testName){ // return ""; // } // } // // Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/DefinitionDeletePageRenderer.java // enum DefinitionDeletePagePosition { // TOP_FORM, // MIDDLE_FORM, // BOTTOM_FORM, // SCRIPT // }
import com.indeed.proctor.webapp.extensions.renderer.DefinitionDeletePageRenderer; import com.indeed.proctor.webapp.extensions.renderer.DefinitionDeletePageRenderer.DefinitionDeletePagePosition; import org.apache.log4j.Logger; import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; import javax.servlet.ServletContext; import javax.servlet.jsp.tagext.TagSupport; import java.io.IOException; import java.util.Map;
package com.indeed.proctor.webapp.tags; /** */ public class RenderDefinitionDeletePageInjectionTemplatesHandler extends TagSupport { private static final Logger LOGGER = Logger.getLogger(RenderDefinitionDeletePageInjectionTemplatesHandler.class); private DefinitionDeletePagePosition position; private String testName; public void setPosition(final DefinitionDeletePagePosition position) { this.position = position; } public void setTestName(final String testName) { this.testName = testName; } public int doStartTag() { try { pageContext.getOut().print(renderTemplates()); } catch (IOException e) { LOGGER.error("Failed to write rendered html to page context", e); } return SKIP_BODY; } private String renderTemplates() { final StringBuilder renderedHTML = new StringBuilder(); final ServletContext servletContext = pageContext.getServletContext(); final WebApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext); try {
// Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/DefinitionDeletePageRenderer.java // public interface DefinitionDeletePageRenderer { // enum DefinitionDeletePagePosition { // TOP_FORM, // MIDDLE_FORM, // BOTTOM_FORM, // SCRIPT // } // // DefinitionDeletePagePosition getDefinitionDeletePagePosition(); // // @Deprecated // default String getRenderedHtml(final String testName){ // return ""; // } // // default String getRenderedHtml(final PageContext pageContext, final String testName){ // return ""; // } // } // // Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/DefinitionDeletePageRenderer.java // enum DefinitionDeletePagePosition { // TOP_FORM, // MIDDLE_FORM, // BOTTOM_FORM, // SCRIPT // } // Path: src/main/java/com/indeed/proctor/webapp/tags/RenderDefinitionDeletePageInjectionTemplatesHandler.java import com.indeed.proctor.webapp.extensions.renderer.DefinitionDeletePageRenderer; import com.indeed.proctor.webapp.extensions.renderer.DefinitionDeletePageRenderer.DefinitionDeletePagePosition; import org.apache.log4j.Logger; import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; import javax.servlet.ServletContext; import javax.servlet.jsp.tagext.TagSupport; import java.io.IOException; import java.util.Map; package com.indeed.proctor.webapp.tags; /** */ public class RenderDefinitionDeletePageInjectionTemplatesHandler extends TagSupport { private static final Logger LOGGER = Logger.getLogger(RenderDefinitionDeletePageInjectionTemplatesHandler.class); private DefinitionDeletePagePosition position; private String testName; public void setPosition(final DefinitionDeletePagePosition position) { this.position = position; } public void setTestName(final String testName) { this.testName = testName; } public int doStartTag() { try { pageContext.getOut().print(renderTemplates()); } catch (IOException e) { LOGGER.error("Failed to write rendered html to page context", e); } return SKIP_BODY; } private String renderTemplates() { final StringBuilder renderedHTML = new StringBuilder(); final ServletContext servletContext = pageContext.getServletContext(); final WebApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext); try {
final Map<String, DefinitionDeletePageRenderer> rendererBeans = BeanFactoryUtils.beansOfTypeIncludingAncestors(context, DefinitionDeletePageRenderer.class);
indeedeng/proctor-webapp-library
src/main/java/com/indeed/proctor/common/ProctorPromoter.java
// Path: src/main/java/com/indeed/proctor/webapp/db/Environment.java // public enum Environment { // WORKING("trunk", 0), // QA("qa", 1), // PRODUCTION("production", 2); // // private final String name; // private final int precedence; // private Environment(final String name, final int precedence) { // this.name = name; // this.precedence = precedence; // } // // public String getName() { // return name; // } // // public int getPrecedence() { // return precedence; // } // // private static final Map<String, Environment> LOOKUP = Maps.uniqueIndex(ImmutableList.copyOf(Environment.values()), Functions.toStringFunction()); // public static Environment fromName(String name) { // if(name == null) { // return null; // } else { // return LOOKUP.get(name.toLowerCase()); // } // } // // @Override // public String toString() { // return this.getName(); // } // } // // Path: src/main/java/com/indeed/proctor/webapp/util/ThreadPoolExecutorVarExports.java // public class ThreadPoolExecutorVarExports { // public ThreadPoolExecutor executor; // // public ThreadPoolExecutorVarExports(final ThreadPoolExecutor executor) { // this.executor = executor; // } // // @Export(name = "total-task-count") // public long getTaskCount() { // return executor.getTaskCount(); // } // // @Export(name = "completed-task-count") // public long getCompletedTaskCount() { // return executor.getCompletedTaskCount(); // } // // @Export(name = "active-threads") // public long getActiveCount() { // return executor.getActiveCount(); // } // // @Export(name = "pool-size") // public long getPoolSize() { // return executor.getPoolSize(); // } // // @Export(name = "max-pool-size") // public long getMaximumPoolSize() { // return executor.getMaximumPoolSize(); // } // // @Export(name = "queue-remaining-capacity") // public int getQueueRemainingCapacity() { // return executor.getQueue().remainingCapacity(); // } // // @Export(name = "core-pool-size") // public long getCorePoolSize() { // return executor.getCorePoolSize(); // } // // @Export(name = "keep-alive-time") // public String getKeepAliveTime() { // return executor.getKeepAliveTime(TimeUnit.SECONDS) + " seconds"; // } // // @Export(name = "queue-size") // public int getQueueSize() { // return executor.getQueue().size(); // } // // @Export(name = "shutdown") // public boolean isShutdown() { // return executor.isShutdown(); // } // }
import com.google.common.base.CharMatcher; import com.google.common.base.Strings; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import com.indeed.proctor.common.model.TestDefinition; import com.indeed.proctor.common.model.TestMatrixDefinition; import com.indeed.proctor.store.GitProctorUtils; import com.indeed.proctor.store.Revision; import com.indeed.proctor.store.StoreException; import com.indeed.proctor.webapp.db.Environment; import com.indeed.proctor.store.ProctorStore; import com.indeed.proctor.webapp.util.ThreadPoolExecutorVarExports; import com.indeed.util.varexport.VarExporter; import org.apache.log4j.Logger; import java.util.List; import java.util.Map; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.regex.Matcher; import java.util.regex.Pattern;
package com.indeed.proctor.common; /** * @author parker */ public class ProctorPromoter { private static final Logger LOGGER = Logger.getLogger(ProctorPromoter.class); private static final String UNKNOWN_VERSION = EnvironmentVersion.UNKNOWN_VERSION; final ProctorStore trunk; final ProctorStore qa; final ProctorStore production; private ExecutorService executor; private final Cache<String, EnvironmentVersion> environmentVersions = CacheBuilder.newBuilder() .maximumSize(2048) .expireAfterWrite(30, TimeUnit.SECONDS) .softValues() .build(); public ProctorPromoter(final ProctorStore trunk, final ProctorStore qa, final ProctorStore production, final ExecutorService executor) { this.trunk = trunk; this.qa = qa; this.production = production; if (executor instanceof ThreadPoolExecutor) { final VarExporter exporter = VarExporter.forNamespace(getClass().getSimpleName());
// Path: src/main/java/com/indeed/proctor/webapp/db/Environment.java // public enum Environment { // WORKING("trunk", 0), // QA("qa", 1), // PRODUCTION("production", 2); // // private final String name; // private final int precedence; // private Environment(final String name, final int precedence) { // this.name = name; // this.precedence = precedence; // } // // public String getName() { // return name; // } // // public int getPrecedence() { // return precedence; // } // // private static final Map<String, Environment> LOOKUP = Maps.uniqueIndex(ImmutableList.copyOf(Environment.values()), Functions.toStringFunction()); // public static Environment fromName(String name) { // if(name == null) { // return null; // } else { // return LOOKUP.get(name.toLowerCase()); // } // } // // @Override // public String toString() { // return this.getName(); // } // } // // Path: src/main/java/com/indeed/proctor/webapp/util/ThreadPoolExecutorVarExports.java // public class ThreadPoolExecutorVarExports { // public ThreadPoolExecutor executor; // // public ThreadPoolExecutorVarExports(final ThreadPoolExecutor executor) { // this.executor = executor; // } // // @Export(name = "total-task-count") // public long getTaskCount() { // return executor.getTaskCount(); // } // // @Export(name = "completed-task-count") // public long getCompletedTaskCount() { // return executor.getCompletedTaskCount(); // } // // @Export(name = "active-threads") // public long getActiveCount() { // return executor.getActiveCount(); // } // // @Export(name = "pool-size") // public long getPoolSize() { // return executor.getPoolSize(); // } // // @Export(name = "max-pool-size") // public long getMaximumPoolSize() { // return executor.getMaximumPoolSize(); // } // // @Export(name = "queue-remaining-capacity") // public int getQueueRemainingCapacity() { // return executor.getQueue().remainingCapacity(); // } // // @Export(name = "core-pool-size") // public long getCorePoolSize() { // return executor.getCorePoolSize(); // } // // @Export(name = "keep-alive-time") // public String getKeepAliveTime() { // return executor.getKeepAliveTime(TimeUnit.SECONDS) + " seconds"; // } // // @Export(name = "queue-size") // public int getQueueSize() { // return executor.getQueue().size(); // } // // @Export(name = "shutdown") // public boolean isShutdown() { // return executor.isShutdown(); // } // } // Path: src/main/java/com/indeed/proctor/common/ProctorPromoter.java import com.google.common.base.CharMatcher; import com.google.common.base.Strings; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import com.indeed.proctor.common.model.TestDefinition; import com.indeed.proctor.common.model.TestMatrixDefinition; import com.indeed.proctor.store.GitProctorUtils; import com.indeed.proctor.store.Revision; import com.indeed.proctor.store.StoreException; import com.indeed.proctor.webapp.db.Environment; import com.indeed.proctor.store.ProctorStore; import com.indeed.proctor.webapp.util.ThreadPoolExecutorVarExports; import com.indeed.util.varexport.VarExporter; import org.apache.log4j.Logger; import java.util.List; import java.util.Map; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.regex.Matcher; import java.util.regex.Pattern; package com.indeed.proctor.common; /** * @author parker */ public class ProctorPromoter { private static final Logger LOGGER = Logger.getLogger(ProctorPromoter.class); private static final String UNKNOWN_VERSION = EnvironmentVersion.UNKNOWN_VERSION; final ProctorStore trunk; final ProctorStore qa; final ProctorStore production; private ExecutorService executor; private final Cache<String, EnvironmentVersion> environmentVersions = CacheBuilder.newBuilder() .maximumSize(2048) .expireAfterWrite(30, TimeUnit.SECONDS) .softValues() .build(); public ProctorPromoter(final ProctorStore trunk, final ProctorStore qa, final ProctorStore production, final ExecutorService executor) { this.trunk = trunk; this.qa = qa; this.production = production; if (executor instanceof ThreadPoolExecutor) { final VarExporter exporter = VarExporter.forNamespace(getClass().getSimpleName());
exporter.export(new ThreadPoolExecutorVarExports((ThreadPoolExecutor) executor), "ProctorPromoter-pool-");
indeedeng/proctor-webapp-library
src/main/java/com/indeed/proctor/common/ProctorPromoter.java
// Path: src/main/java/com/indeed/proctor/webapp/db/Environment.java // public enum Environment { // WORKING("trunk", 0), // QA("qa", 1), // PRODUCTION("production", 2); // // private final String name; // private final int precedence; // private Environment(final String name, final int precedence) { // this.name = name; // this.precedence = precedence; // } // // public String getName() { // return name; // } // // public int getPrecedence() { // return precedence; // } // // private static final Map<String, Environment> LOOKUP = Maps.uniqueIndex(ImmutableList.copyOf(Environment.values()), Functions.toStringFunction()); // public static Environment fromName(String name) { // if(name == null) { // return null; // } else { // return LOOKUP.get(name.toLowerCase()); // } // } // // @Override // public String toString() { // return this.getName(); // } // } // // Path: src/main/java/com/indeed/proctor/webapp/util/ThreadPoolExecutorVarExports.java // public class ThreadPoolExecutorVarExports { // public ThreadPoolExecutor executor; // // public ThreadPoolExecutorVarExports(final ThreadPoolExecutor executor) { // this.executor = executor; // } // // @Export(name = "total-task-count") // public long getTaskCount() { // return executor.getTaskCount(); // } // // @Export(name = "completed-task-count") // public long getCompletedTaskCount() { // return executor.getCompletedTaskCount(); // } // // @Export(name = "active-threads") // public long getActiveCount() { // return executor.getActiveCount(); // } // // @Export(name = "pool-size") // public long getPoolSize() { // return executor.getPoolSize(); // } // // @Export(name = "max-pool-size") // public long getMaximumPoolSize() { // return executor.getMaximumPoolSize(); // } // // @Export(name = "queue-remaining-capacity") // public int getQueueRemainingCapacity() { // return executor.getQueue().remainingCapacity(); // } // // @Export(name = "core-pool-size") // public long getCorePoolSize() { // return executor.getCorePoolSize(); // } // // @Export(name = "keep-alive-time") // public String getKeepAliveTime() { // return executor.getKeepAliveTime(TimeUnit.SECONDS) + " seconds"; // } // // @Export(name = "queue-size") // public int getQueueSize() { // return executor.getQueue().size(); // } // // @Export(name = "shutdown") // public boolean isShutdown() { // return executor.isShutdown(); // } // }
import com.google.common.base.CharMatcher; import com.google.common.base.Strings; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import com.indeed.proctor.common.model.TestDefinition; import com.indeed.proctor.common.model.TestMatrixDefinition; import com.indeed.proctor.store.GitProctorUtils; import com.indeed.proctor.store.Revision; import com.indeed.proctor.store.StoreException; import com.indeed.proctor.webapp.db.Environment; import com.indeed.proctor.store.ProctorStore; import com.indeed.proctor.webapp.util.ThreadPoolExecutorVarExports; import com.indeed.util.varexport.VarExporter; import org.apache.log4j.Logger; import java.util.List; import java.util.Map; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.regex.Matcher; import java.util.regex.Pattern;
package com.indeed.proctor.common; /** * @author parker */ public class ProctorPromoter { private static final Logger LOGGER = Logger.getLogger(ProctorPromoter.class); private static final String UNKNOWN_VERSION = EnvironmentVersion.UNKNOWN_VERSION; final ProctorStore trunk; final ProctorStore qa; final ProctorStore production; private ExecutorService executor; private final Cache<String, EnvironmentVersion> environmentVersions = CacheBuilder.newBuilder() .maximumSize(2048) .expireAfterWrite(30, TimeUnit.SECONDS) .softValues() .build(); public ProctorPromoter(final ProctorStore trunk, final ProctorStore qa, final ProctorStore production, final ExecutorService executor) { this.trunk = trunk; this.qa = qa; this.production = production; if (executor instanceof ThreadPoolExecutor) { final VarExporter exporter = VarExporter.forNamespace(getClass().getSimpleName()); exporter.export(new ThreadPoolExecutorVarExports((ThreadPoolExecutor) executor), "ProctorPromoter-pool-"); } this.executor = executor; } public void promoteTrunkToQa(final String testName, String trunkRevision, String qaRevision, String username, String password, String author, Map<String, String> metadata) throws StoreException, TestPromotionException {
// Path: src/main/java/com/indeed/proctor/webapp/db/Environment.java // public enum Environment { // WORKING("trunk", 0), // QA("qa", 1), // PRODUCTION("production", 2); // // private final String name; // private final int precedence; // private Environment(final String name, final int precedence) { // this.name = name; // this.precedence = precedence; // } // // public String getName() { // return name; // } // // public int getPrecedence() { // return precedence; // } // // private static final Map<String, Environment> LOOKUP = Maps.uniqueIndex(ImmutableList.copyOf(Environment.values()), Functions.toStringFunction()); // public static Environment fromName(String name) { // if(name == null) { // return null; // } else { // return LOOKUP.get(name.toLowerCase()); // } // } // // @Override // public String toString() { // return this.getName(); // } // } // // Path: src/main/java/com/indeed/proctor/webapp/util/ThreadPoolExecutorVarExports.java // public class ThreadPoolExecutorVarExports { // public ThreadPoolExecutor executor; // // public ThreadPoolExecutorVarExports(final ThreadPoolExecutor executor) { // this.executor = executor; // } // // @Export(name = "total-task-count") // public long getTaskCount() { // return executor.getTaskCount(); // } // // @Export(name = "completed-task-count") // public long getCompletedTaskCount() { // return executor.getCompletedTaskCount(); // } // // @Export(name = "active-threads") // public long getActiveCount() { // return executor.getActiveCount(); // } // // @Export(name = "pool-size") // public long getPoolSize() { // return executor.getPoolSize(); // } // // @Export(name = "max-pool-size") // public long getMaximumPoolSize() { // return executor.getMaximumPoolSize(); // } // // @Export(name = "queue-remaining-capacity") // public int getQueueRemainingCapacity() { // return executor.getQueue().remainingCapacity(); // } // // @Export(name = "core-pool-size") // public long getCorePoolSize() { // return executor.getCorePoolSize(); // } // // @Export(name = "keep-alive-time") // public String getKeepAliveTime() { // return executor.getKeepAliveTime(TimeUnit.SECONDS) + " seconds"; // } // // @Export(name = "queue-size") // public int getQueueSize() { // return executor.getQueue().size(); // } // // @Export(name = "shutdown") // public boolean isShutdown() { // return executor.isShutdown(); // } // } // Path: src/main/java/com/indeed/proctor/common/ProctorPromoter.java import com.google.common.base.CharMatcher; import com.google.common.base.Strings; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import com.indeed.proctor.common.model.TestDefinition; import com.indeed.proctor.common.model.TestMatrixDefinition; import com.indeed.proctor.store.GitProctorUtils; import com.indeed.proctor.store.Revision; import com.indeed.proctor.store.StoreException; import com.indeed.proctor.webapp.db.Environment; import com.indeed.proctor.store.ProctorStore; import com.indeed.proctor.webapp.util.ThreadPoolExecutorVarExports; import com.indeed.util.varexport.VarExporter; import org.apache.log4j.Logger; import java.util.List; import java.util.Map; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.regex.Matcher; import java.util.regex.Pattern; package com.indeed.proctor.common; /** * @author parker */ public class ProctorPromoter { private static final Logger LOGGER = Logger.getLogger(ProctorPromoter.class); private static final String UNKNOWN_VERSION = EnvironmentVersion.UNKNOWN_VERSION; final ProctorStore trunk; final ProctorStore qa; final ProctorStore production; private ExecutorService executor; private final Cache<String, EnvironmentVersion> environmentVersions = CacheBuilder.newBuilder() .maximumSize(2048) .expireAfterWrite(30, TimeUnit.SECONDS) .softValues() .build(); public ProctorPromoter(final ProctorStore trunk, final ProctorStore qa, final ProctorStore production, final ExecutorService executor) { this.trunk = trunk; this.qa = qa; this.production = production; if (executor instanceof ThreadPoolExecutor) { final VarExporter exporter = VarExporter.forNamespace(getClass().getSimpleName()); exporter.export(new ThreadPoolExecutorVarExports((ThreadPoolExecutor) executor), "ProctorPromoter-pool-"); } this.executor = executor; } public void promoteTrunkToQa(final String testName, String trunkRevision, String qaRevision, String username, String password, String author, Map<String, String> metadata) throws StoreException, TestPromotionException {
promote(testName, Environment.WORKING, trunkRevision, Environment.QA, qaRevision, username, password, author, metadata);
indeedeng/proctor-webapp-library
src/main/java/com/indeed/proctor/webapp/tags/RenderHelpButtonTagHandler.java
// Path: src/main/java/com/indeed/proctor/webapp/extensions/HelpURLInformation.java // public interface HelpURLInformation { // public String getTestTypeHelpURL(); // public String getRuleHelpURL(); // }
import com.indeed.proctor.webapp.extensions.HelpURLInformation; import org.apache.log4j.Logger; import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; import javax.servlet.ServletContext; import javax.servlet.jsp.tagext.TagSupport; import java.io.IOException; import java.util.Map;
package com.indeed.proctor.webapp.tags; /** * @author yosukey */ public class RenderHelpButtonTagHandler extends TagSupport { public enum HelpType { TEST_TYPE, RULE } private static final String TEST_TYPE_DEFAULT_URL = "http://opensource.indeedeng.io/proctor/docs/terminology/#test-type"; private static final String RULE_DEFAULT_URL = "http://opensource.indeedeng.io/proctor/docs/test-rules/"; private static final Logger LOGGER = Logger.getLogger(RenderHelpButtonTagHandler.class); private HelpType helpType; public void setHelpType(HelpType helpType) { this.helpType = helpType; } public int doStartTag() { try { pageContext.getOut().print(helpButton(helpType)); } catch (IOException e) { LOGGER.error("Failed to write help button to page context", e); } return SKIP_BODY; } public String helpButton(final HelpType helpType) { return String.format("<a class=\"ui-help-button\" target=\"_blank\" href=\"%s\">?</a>", getHelpURL(helpType)); } public String getHelpURL(final HelpType helpType) { final ServletContext servletContext = pageContext.getServletContext(); final WebApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
// Path: src/main/java/com/indeed/proctor/webapp/extensions/HelpURLInformation.java // public interface HelpURLInformation { // public String getTestTypeHelpURL(); // public String getRuleHelpURL(); // } // Path: src/main/java/com/indeed/proctor/webapp/tags/RenderHelpButtonTagHandler.java import com.indeed.proctor.webapp.extensions.HelpURLInformation; import org.apache.log4j.Logger; import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; import javax.servlet.ServletContext; import javax.servlet.jsp.tagext.TagSupport; import java.io.IOException; import java.util.Map; package com.indeed.proctor.webapp.tags; /** * @author yosukey */ public class RenderHelpButtonTagHandler extends TagSupport { public enum HelpType { TEST_TYPE, RULE } private static final String TEST_TYPE_DEFAULT_URL = "http://opensource.indeedeng.io/proctor/docs/terminology/#test-type"; private static final String RULE_DEFAULT_URL = "http://opensource.indeedeng.io/proctor/docs/test-rules/"; private static final Logger LOGGER = Logger.getLogger(RenderHelpButtonTagHandler.class); private HelpType helpType; public void setHelpType(HelpType helpType) { this.helpType = helpType; } public int doStartTag() { try { pageContext.getOut().print(helpButton(helpType)); } catch (IOException e) { LOGGER.error("Failed to write help button to page context", e); } return SKIP_BODY; } public String helpButton(final HelpType helpType) { return String.format("<a class=\"ui-help-button\" target=\"_blank\" href=\"%s\">?</a>", getHelpURL(helpType)); } public String getHelpURL(final HelpType helpType) { final ServletContext servletContext = pageContext.getServletContext(); final WebApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
final Map<String, HelpURLInformation> formatterBeans = BeanFactoryUtils.beansOfTypeIncludingAncestors(context, HelpURLInformation.class);
indeedeng/proctor-webapp-library
src/main/java/com/indeed/proctor/webapp/jobs/BackgroundJobManager.java
// Path: src/main/java/com/indeed/proctor/webapp/extensions/JobInfoStore.java // public interface JobInfoStore { // boolean shouldUpdateJobInfo(final BackgroundJob job); // // void updateJobInfo(final UUID uuid, final BackgroundJob.JobInfo jobInfo); // // BackgroundJob.JobInfo getJobInfo(final UUID uuid); // } // // Path: src/main/java/com/indeed/proctor/webapp/util/ThreadPoolExecutorVarExports.java // public class ThreadPoolExecutorVarExports { // public ThreadPoolExecutor executor; // // public ThreadPoolExecutorVarExports(final ThreadPoolExecutor executor) { // this.executor = executor; // } // // @Export(name = "total-task-count") // public long getTaskCount() { // return executor.getTaskCount(); // } // // @Export(name = "completed-task-count") // public long getCompletedTaskCount() { // return executor.getCompletedTaskCount(); // } // // @Export(name = "active-threads") // public long getActiveCount() { // return executor.getActiveCount(); // } // // @Export(name = "pool-size") // public long getPoolSize() { // return executor.getPoolSize(); // } // // @Export(name = "max-pool-size") // public long getMaximumPoolSize() { // return executor.getMaximumPoolSize(); // } // // @Export(name = "queue-remaining-capacity") // public int getQueueRemainingCapacity() { // return executor.getQueue().remainingCapacity(); // } // // @Export(name = "core-pool-size") // public long getCorePoolSize() { // return executor.getCorePoolSize(); // } // // @Export(name = "keep-alive-time") // public String getKeepAliveTime() { // return executor.getKeepAliveTime(TimeUnit.SECONDS) + " seconds"; // } // // @Export(name = "queue-size") // public int getQueueSize() { // return executor.getQueue().size(); // } // // @Export(name = "shutdown") // public boolean isShutdown() { // return executor.isShutdown(); // } // } // // Path: src/main/java/com/indeed/proctor/webapp/util/threads/LogOnUncaughtExceptionHandler.java // public class LogOnUncaughtExceptionHandler implements UncaughtExceptionHandler { // private Logger logger = Logger.getLogger(LogOnUncaughtExceptionHandler.class); // // public LogOnUncaughtExceptionHandler(){} // // // public LogOnUncaughtExceptionHandler(final Logger logger) { // this.logger = logger; // } // // public void setLogger(final Logger logger) { // this.logger = logger; // } // // @Override // public void uncaughtException(final Thread t, final Throwable e) { // logger.error("Uncaught throwable in thread " + t.getName() + "/" + t.getId(), e); // } // }
import com.google.common.collect.Lists; import com.google.common.collect.MapMaker; import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.indeed.proctor.webapp.extensions.JobInfoStore; import com.indeed.proctor.webapp.util.ThreadPoolExecutorVarExports; import com.indeed.proctor.webapp.util.threads.LogOnUncaughtExceptionHandler; import com.indeed.util.varexport.VarExporter; import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.Scheduled; import javax.annotation.Nullable; import java.util.List; import java.util.ListIterator; import java.util.Map; import java.util.UUID; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong;
package com.indeed.proctor.webapp.jobs; @EnableScheduling public class BackgroundJobManager { private static final Logger LOGGER = Logger.getLogger(BackgroundJobManager.class); private final List<BackgroundJob> backgroundJobs = Lists.newLinkedList(); private final ExecutorService service; private final Map<UUID, BackgroundJob> history = new MapMaker() .softValues() .makeMap(); private final AtomicLong lastId = new AtomicLong(0);
// Path: src/main/java/com/indeed/proctor/webapp/extensions/JobInfoStore.java // public interface JobInfoStore { // boolean shouldUpdateJobInfo(final BackgroundJob job); // // void updateJobInfo(final UUID uuid, final BackgroundJob.JobInfo jobInfo); // // BackgroundJob.JobInfo getJobInfo(final UUID uuid); // } // // Path: src/main/java/com/indeed/proctor/webapp/util/ThreadPoolExecutorVarExports.java // public class ThreadPoolExecutorVarExports { // public ThreadPoolExecutor executor; // // public ThreadPoolExecutorVarExports(final ThreadPoolExecutor executor) { // this.executor = executor; // } // // @Export(name = "total-task-count") // public long getTaskCount() { // return executor.getTaskCount(); // } // // @Export(name = "completed-task-count") // public long getCompletedTaskCount() { // return executor.getCompletedTaskCount(); // } // // @Export(name = "active-threads") // public long getActiveCount() { // return executor.getActiveCount(); // } // // @Export(name = "pool-size") // public long getPoolSize() { // return executor.getPoolSize(); // } // // @Export(name = "max-pool-size") // public long getMaximumPoolSize() { // return executor.getMaximumPoolSize(); // } // // @Export(name = "queue-remaining-capacity") // public int getQueueRemainingCapacity() { // return executor.getQueue().remainingCapacity(); // } // // @Export(name = "core-pool-size") // public long getCorePoolSize() { // return executor.getCorePoolSize(); // } // // @Export(name = "keep-alive-time") // public String getKeepAliveTime() { // return executor.getKeepAliveTime(TimeUnit.SECONDS) + " seconds"; // } // // @Export(name = "queue-size") // public int getQueueSize() { // return executor.getQueue().size(); // } // // @Export(name = "shutdown") // public boolean isShutdown() { // return executor.isShutdown(); // } // } // // Path: src/main/java/com/indeed/proctor/webapp/util/threads/LogOnUncaughtExceptionHandler.java // public class LogOnUncaughtExceptionHandler implements UncaughtExceptionHandler { // private Logger logger = Logger.getLogger(LogOnUncaughtExceptionHandler.class); // // public LogOnUncaughtExceptionHandler(){} // // // public LogOnUncaughtExceptionHandler(final Logger logger) { // this.logger = logger; // } // // public void setLogger(final Logger logger) { // this.logger = logger; // } // // @Override // public void uncaughtException(final Thread t, final Throwable e) { // logger.error("Uncaught throwable in thread " + t.getName() + "/" + t.getId(), e); // } // } // Path: src/main/java/com/indeed/proctor/webapp/jobs/BackgroundJobManager.java import com.google.common.collect.Lists; import com.google.common.collect.MapMaker; import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.indeed.proctor.webapp.extensions.JobInfoStore; import com.indeed.proctor.webapp.util.ThreadPoolExecutorVarExports; import com.indeed.proctor.webapp.util.threads.LogOnUncaughtExceptionHandler; import com.indeed.util.varexport.VarExporter; import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.Scheduled; import javax.annotation.Nullable; import java.util.List; import java.util.ListIterator; import java.util.Map; import java.util.UUID; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; package com.indeed.proctor.webapp.jobs; @EnableScheduling public class BackgroundJobManager { private static final Logger LOGGER = Logger.getLogger(BackgroundJobManager.class); private final List<BackgroundJob> backgroundJobs = Lists.newLinkedList(); private final ExecutorService service; private final Map<UUID, BackgroundJob> history = new MapMaker() .softValues() .makeMap(); private final AtomicLong lastId = new AtomicLong(0);
private JobInfoStore jobInfoStore;
indeedeng/proctor-webapp-library
src/main/java/com/indeed/proctor/webapp/jobs/BackgroundJobManager.java
// Path: src/main/java/com/indeed/proctor/webapp/extensions/JobInfoStore.java // public interface JobInfoStore { // boolean shouldUpdateJobInfo(final BackgroundJob job); // // void updateJobInfo(final UUID uuid, final BackgroundJob.JobInfo jobInfo); // // BackgroundJob.JobInfo getJobInfo(final UUID uuid); // } // // Path: src/main/java/com/indeed/proctor/webapp/util/ThreadPoolExecutorVarExports.java // public class ThreadPoolExecutorVarExports { // public ThreadPoolExecutor executor; // // public ThreadPoolExecutorVarExports(final ThreadPoolExecutor executor) { // this.executor = executor; // } // // @Export(name = "total-task-count") // public long getTaskCount() { // return executor.getTaskCount(); // } // // @Export(name = "completed-task-count") // public long getCompletedTaskCount() { // return executor.getCompletedTaskCount(); // } // // @Export(name = "active-threads") // public long getActiveCount() { // return executor.getActiveCount(); // } // // @Export(name = "pool-size") // public long getPoolSize() { // return executor.getPoolSize(); // } // // @Export(name = "max-pool-size") // public long getMaximumPoolSize() { // return executor.getMaximumPoolSize(); // } // // @Export(name = "queue-remaining-capacity") // public int getQueueRemainingCapacity() { // return executor.getQueue().remainingCapacity(); // } // // @Export(name = "core-pool-size") // public long getCorePoolSize() { // return executor.getCorePoolSize(); // } // // @Export(name = "keep-alive-time") // public String getKeepAliveTime() { // return executor.getKeepAliveTime(TimeUnit.SECONDS) + " seconds"; // } // // @Export(name = "queue-size") // public int getQueueSize() { // return executor.getQueue().size(); // } // // @Export(name = "shutdown") // public boolean isShutdown() { // return executor.isShutdown(); // } // } // // Path: src/main/java/com/indeed/proctor/webapp/util/threads/LogOnUncaughtExceptionHandler.java // public class LogOnUncaughtExceptionHandler implements UncaughtExceptionHandler { // private Logger logger = Logger.getLogger(LogOnUncaughtExceptionHandler.class); // // public LogOnUncaughtExceptionHandler(){} // // // public LogOnUncaughtExceptionHandler(final Logger logger) { // this.logger = logger; // } // // public void setLogger(final Logger logger) { // this.logger = logger; // } // // @Override // public void uncaughtException(final Thread t, final Throwable e) { // logger.error("Uncaught throwable in thread " + t.getName() + "/" + t.getId(), e); // } // }
import com.google.common.collect.Lists; import com.google.common.collect.MapMaker; import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.indeed.proctor.webapp.extensions.JobInfoStore; import com.indeed.proctor.webapp.util.ThreadPoolExecutorVarExports; import com.indeed.proctor.webapp.util.threads.LogOnUncaughtExceptionHandler; import com.indeed.util.varexport.VarExporter; import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.Scheduled; import javax.annotation.Nullable; import java.util.List; import java.util.ListIterator; import java.util.Map; import java.util.UUID; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong;
package com.indeed.proctor.webapp.jobs; @EnableScheduling public class BackgroundJobManager { private static final Logger LOGGER = Logger.getLogger(BackgroundJobManager.class); private final List<BackgroundJob> backgroundJobs = Lists.newLinkedList(); private final ExecutorService service; private final Map<UUID, BackgroundJob> history = new MapMaker() .softValues() .makeMap(); private final AtomicLong lastId = new AtomicLong(0); private JobInfoStore jobInfoStore; public BackgroundJobManager() { this(initThreadPool()); } public BackgroundJobManager(final ThreadPoolExecutor executor) { final VarExporter exporter = VarExporter.forNamespace(getClass().getSimpleName());
// Path: src/main/java/com/indeed/proctor/webapp/extensions/JobInfoStore.java // public interface JobInfoStore { // boolean shouldUpdateJobInfo(final BackgroundJob job); // // void updateJobInfo(final UUID uuid, final BackgroundJob.JobInfo jobInfo); // // BackgroundJob.JobInfo getJobInfo(final UUID uuid); // } // // Path: src/main/java/com/indeed/proctor/webapp/util/ThreadPoolExecutorVarExports.java // public class ThreadPoolExecutorVarExports { // public ThreadPoolExecutor executor; // // public ThreadPoolExecutorVarExports(final ThreadPoolExecutor executor) { // this.executor = executor; // } // // @Export(name = "total-task-count") // public long getTaskCount() { // return executor.getTaskCount(); // } // // @Export(name = "completed-task-count") // public long getCompletedTaskCount() { // return executor.getCompletedTaskCount(); // } // // @Export(name = "active-threads") // public long getActiveCount() { // return executor.getActiveCount(); // } // // @Export(name = "pool-size") // public long getPoolSize() { // return executor.getPoolSize(); // } // // @Export(name = "max-pool-size") // public long getMaximumPoolSize() { // return executor.getMaximumPoolSize(); // } // // @Export(name = "queue-remaining-capacity") // public int getQueueRemainingCapacity() { // return executor.getQueue().remainingCapacity(); // } // // @Export(name = "core-pool-size") // public long getCorePoolSize() { // return executor.getCorePoolSize(); // } // // @Export(name = "keep-alive-time") // public String getKeepAliveTime() { // return executor.getKeepAliveTime(TimeUnit.SECONDS) + " seconds"; // } // // @Export(name = "queue-size") // public int getQueueSize() { // return executor.getQueue().size(); // } // // @Export(name = "shutdown") // public boolean isShutdown() { // return executor.isShutdown(); // } // } // // Path: src/main/java/com/indeed/proctor/webapp/util/threads/LogOnUncaughtExceptionHandler.java // public class LogOnUncaughtExceptionHandler implements UncaughtExceptionHandler { // private Logger logger = Logger.getLogger(LogOnUncaughtExceptionHandler.class); // // public LogOnUncaughtExceptionHandler(){} // // // public LogOnUncaughtExceptionHandler(final Logger logger) { // this.logger = logger; // } // // public void setLogger(final Logger logger) { // this.logger = logger; // } // // @Override // public void uncaughtException(final Thread t, final Throwable e) { // logger.error("Uncaught throwable in thread " + t.getName() + "/" + t.getId(), e); // } // } // Path: src/main/java/com/indeed/proctor/webapp/jobs/BackgroundJobManager.java import com.google.common.collect.Lists; import com.google.common.collect.MapMaker; import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.indeed.proctor.webapp.extensions.JobInfoStore; import com.indeed.proctor.webapp.util.ThreadPoolExecutorVarExports; import com.indeed.proctor.webapp.util.threads.LogOnUncaughtExceptionHandler; import com.indeed.util.varexport.VarExporter; import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.Scheduled; import javax.annotation.Nullable; import java.util.List; import java.util.ListIterator; import java.util.Map; import java.util.UUID; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; package com.indeed.proctor.webapp.jobs; @EnableScheduling public class BackgroundJobManager { private static final Logger LOGGER = Logger.getLogger(BackgroundJobManager.class); private final List<BackgroundJob> backgroundJobs = Lists.newLinkedList(); private final ExecutorService service; private final Map<UUID, BackgroundJob> history = new MapMaker() .softValues() .makeMap(); private final AtomicLong lastId = new AtomicLong(0); private JobInfoStore jobInfoStore; public BackgroundJobManager() { this(initThreadPool()); } public BackgroundJobManager(final ThreadPoolExecutor executor) { final VarExporter exporter = VarExporter.forNamespace(getClass().getSimpleName());
exporter.export(new ThreadPoolExecutorVarExports(executor), "pool-");
indeedeng/proctor-webapp-library
src/main/java/com/indeed/proctor/webapp/jobs/BackgroundJobManager.java
// Path: src/main/java/com/indeed/proctor/webapp/extensions/JobInfoStore.java // public interface JobInfoStore { // boolean shouldUpdateJobInfo(final BackgroundJob job); // // void updateJobInfo(final UUID uuid, final BackgroundJob.JobInfo jobInfo); // // BackgroundJob.JobInfo getJobInfo(final UUID uuid); // } // // Path: src/main/java/com/indeed/proctor/webapp/util/ThreadPoolExecutorVarExports.java // public class ThreadPoolExecutorVarExports { // public ThreadPoolExecutor executor; // // public ThreadPoolExecutorVarExports(final ThreadPoolExecutor executor) { // this.executor = executor; // } // // @Export(name = "total-task-count") // public long getTaskCount() { // return executor.getTaskCount(); // } // // @Export(name = "completed-task-count") // public long getCompletedTaskCount() { // return executor.getCompletedTaskCount(); // } // // @Export(name = "active-threads") // public long getActiveCount() { // return executor.getActiveCount(); // } // // @Export(name = "pool-size") // public long getPoolSize() { // return executor.getPoolSize(); // } // // @Export(name = "max-pool-size") // public long getMaximumPoolSize() { // return executor.getMaximumPoolSize(); // } // // @Export(name = "queue-remaining-capacity") // public int getQueueRemainingCapacity() { // return executor.getQueue().remainingCapacity(); // } // // @Export(name = "core-pool-size") // public long getCorePoolSize() { // return executor.getCorePoolSize(); // } // // @Export(name = "keep-alive-time") // public String getKeepAliveTime() { // return executor.getKeepAliveTime(TimeUnit.SECONDS) + " seconds"; // } // // @Export(name = "queue-size") // public int getQueueSize() { // return executor.getQueue().size(); // } // // @Export(name = "shutdown") // public boolean isShutdown() { // return executor.isShutdown(); // } // } // // Path: src/main/java/com/indeed/proctor/webapp/util/threads/LogOnUncaughtExceptionHandler.java // public class LogOnUncaughtExceptionHandler implements UncaughtExceptionHandler { // private Logger logger = Logger.getLogger(LogOnUncaughtExceptionHandler.class); // // public LogOnUncaughtExceptionHandler(){} // // // public LogOnUncaughtExceptionHandler(final Logger logger) { // this.logger = logger; // } // // public void setLogger(final Logger logger) { // this.logger = logger; // } // // @Override // public void uncaughtException(final Thread t, final Throwable e) { // logger.error("Uncaught throwable in thread " + t.getName() + "/" + t.getId(), e); // } // }
import com.google.common.collect.Lists; import com.google.common.collect.MapMaker; import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.indeed.proctor.webapp.extensions.JobInfoStore; import com.indeed.proctor.webapp.util.ThreadPoolExecutorVarExports; import com.indeed.proctor.webapp.util.threads.LogOnUncaughtExceptionHandler; import com.indeed.util.varexport.VarExporter; import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.Scheduled; import javax.annotation.Nullable; import java.util.List; import java.util.ListIterator; import java.util.Map; import java.util.UUID; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong;
package com.indeed.proctor.webapp.jobs; @EnableScheduling public class BackgroundJobManager { private static final Logger LOGGER = Logger.getLogger(BackgroundJobManager.class); private final List<BackgroundJob> backgroundJobs = Lists.newLinkedList(); private final ExecutorService service; private final Map<UUID, BackgroundJob> history = new MapMaker() .softValues() .makeMap(); private final AtomicLong lastId = new AtomicLong(0); private JobInfoStore jobInfoStore; public BackgroundJobManager() { this(initThreadPool()); } public BackgroundJobManager(final ThreadPoolExecutor executor) { final VarExporter exporter = VarExporter.forNamespace(getClass().getSimpleName()); exporter.export(new ThreadPoolExecutorVarExports(executor), "pool-"); this.service = executor; } private static ThreadPoolExecutor initThreadPool() { final ThreadFactory threadFactory = new ThreadFactoryBuilder() .setNameFormat(BackgroundJobManager.class.getSimpleName() + "-Thread-%d")
// Path: src/main/java/com/indeed/proctor/webapp/extensions/JobInfoStore.java // public interface JobInfoStore { // boolean shouldUpdateJobInfo(final BackgroundJob job); // // void updateJobInfo(final UUID uuid, final BackgroundJob.JobInfo jobInfo); // // BackgroundJob.JobInfo getJobInfo(final UUID uuid); // } // // Path: src/main/java/com/indeed/proctor/webapp/util/ThreadPoolExecutorVarExports.java // public class ThreadPoolExecutorVarExports { // public ThreadPoolExecutor executor; // // public ThreadPoolExecutorVarExports(final ThreadPoolExecutor executor) { // this.executor = executor; // } // // @Export(name = "total-task-count") // public long getTaskCount() { // return executor.getTaskCount(); // } // // @Export(name = "completed-task-count") // public long getCompletedTaskCount() { // return executor.getCompletedTaskCount(); // } // // @Export(name = "active-threads") // public long getActiveCount() { // return executor.getActiveCount(); // } // // @Export(name = "pool-size") // public long getPoolSize() { // return executor.getPoolSize(); // } // // @Export(name = "max-pool-size") // public long getMaximumPoolSize() { // return executor.getMaximumPoolSize(); // } // // @Export(name = "queue-remaining-capacity") // public int getQueueRemainingCapacity() { // return executor.getQueue().remainingCapacity(); // } // // @Export(name = "core-pool-size") // public long getCorePoolSize() { // return executor.getCorePoolSize(); // } // // @Export(name = "keep-alive-time") // public String getKeepAliveTime() { // return executor.getKeepAliveTime(TimeUnit.SECONDS) + " seconds"; // } // // @Export(name = "queue-size") // public int getQueueSize() { // return executor.getQueue().size(); // } // // @Export(name = "shutdown") // public boolean isShutdown() { // return executor.isShutdown(); // } // } // // Path: src/main/java/com/indeed/proctor/webapp/util/threads/LogOnUncaughtExceptionHandler.java // public class LogOnUncaughtExceptionHandler implements UncaughtExceptionHandler { // private Logger logger = Logger.getLogger(LogOnUncaughtExceptionHandler.class); // // public LogOnUncaughtExceptionHandler(){} // // // public LogOnUncaughtExceptionHandler(final Logger logger) { // this.logger = logger; // } // // public void setLogger(final Logger logger) { // this.logger = logger; // } // // @Override // public void uncaughtException(final Thread t, final Throwable e) { // logger.error("Uncaught throwable in thread " + t.getName() + "/" + t.getId(), e); // } // } // Path: src/main/java/com/indeed/proctor/webapp/jobs/BackgroundJobManager.java import com.google.common.collect.Lists; import com.google.common.collect.MapMaker; import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.indeed.proctor.webapp.extensions.JobInfoStore; import com.indeed.proctor.webapp.util.ThreadPoolExecutorVarExports; import com.indeed.proctor.webapp.util.threads.LogOnUncaughtExceptionHandler; import com.indeed.util.varexport.VarExporter; import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.Scheduled; import javax.annotation.Nullable; import java.util.List; import java.util.ListIterator; import java.util.Map; import java.util.UUID; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; package com.indeed.proctor.webapp.jobs; @EnableScheduling public class BackgroundJobManager { private static final Logger LOGGER = Logger.getLogger(BackgroundJobManager.class); private final List<BackgroundJob> backgroundJobs = Lists.newLinkedList(); private final ExecutorService service; private final Map<UUID, BackgroundJob> history = new MapMaker() .softValues() .makeMap(); private final AtomicLong lastId = new AtomicLong(0); private JobInfoStore jobInfoStore; public BackgroundJobManager() { this(initThreadPool()); } public BackgroundJobManager(final ThreadPoolExecutor executor) { final VarExporter exporter = VarExporter.forNamespace(getClass().getSimpleName()); exporter.export(new ThreadPoolExecutorVarExports(executor), "pool-"); this.service = executor; } private static ThreadPoolExecutor initThreadPool() { final ThreadFactory threadFactory = new ThreadFactoryBuilder() .setNameFormat(BackgroundJobManager.class.getSimpleName() + "-Thread-%d")
.setUncaughtExceptionHandler(new LogOnUncaughtExceptionHandler())
indeedeng/proctor-webapp-library
src/main/java/com/indeed/proctor/webapp/tags/RenderBasePageInjectionTemplatesHandler.java
// Path: src/main/java/com/indeed/proctor/webapp/db/Environment.java // public enum Environment { // WORKING("trunk", 0), // QA("qa", 1), // PRODUCTION("production", 2); // // private final String name; // private final int precedence; // private Environment(final String name, final int precedence) { // this.name = name; // this.precedence = precedence; // } // // public String getName() { // return name; // } // // public int getPrecedence() { // return precedence; // } // // private static final Map<String, Environment> LOOKUP = Maps.uniqueIndex(ImmutableList.copyOf(Environment.values()), Functions.toStringFunction()); // public static Environment fromName(String name) { // if(name == null) { // return null; // } else { // return LOOKUP.get(name.toLowerCase()); // } // } // // @Override // public String toString() { // return this.getName(); // } // } // // Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/BasePageRenderer.java // public interface BasePageRenderer { // enum BasePagePosition { // HEAD, // NAVBAR_BUTTON, // FOOTER, // } // // BasePagePosition getBasePagePosition(); // // @Deprecated // default String getRenderedHtml(final Environment branch) { // return ""; // } // // default String getRenderedHtml(final PageContext pageContext, final Environment branch) { // return ""; // } // } // // Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/BasePageRenderer.java // enum BasePagePosition { // HEAD, // NAVBAR_BUTTON, // FOOTER, // }
import com.indeed.proctor.webapp.db.Environment; import com.indeed.proctor.webapp.extensions.renderer.BasePageRenderer; import com.indeed.proctor.webapp.extensions.renderer.BasePageRenderer.BasePagePosition; import org.apache.log4j.Logger; import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; import javax.servlet.ServletContext; import javax.servlet.jsp.tagext.TagSupport; import java.io.IOException; import java.util.Map;
package com.indeed.proctor.webapp.tags; /** */ public class RenderBasePageInjectionTemplatesHandler extends TagSupport { private static final Logger LOGGER = Logger.getLogger(RenderBasePageInjectionTemplatesHandler.class);
// Path: src/main/java/com/indeed/proctor/webapp/db/Environment.java // public enum Environment { // WORKING("trunk", 0), // QA("qa", 1), // PRODUCTION("production", 2); // // private final String name; // private final int precedence; // private Environment(final String name, final int precedence) { // this.name = name; // this.precedence = precedence; // } // // public String getName() { // return name; // } // // public int getPrecedence() { // return precedence; // } // // private static final Map<String, Environment> LOOKUP = Maps.uniqueIndex(ImmutableList.copyOf(Environment.values()), Functions.toStringFunction()); // public static Environment fromName(String name) { // if(name == null) { // return null; // } else { // return LOOKUP.get(name.toLowerCase()); // } // } // // @Override // public String toString() { // return this.getName(); // } // } // // Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/BasePageRenderer.java // public interface BasePageRenderer { // enum BasePagePosition { // HEAD, // NAVBAR_BUTTON, // FOOTER, // } // // BasePagePosition getBasePagePosition(); // // @Deprecated // default String getRenderedHtml(final Environment branch) { // return ""; // } // // default String getRenderedHtml(final PageContext pageContext, final Environment branch) { // return ""; // } // } // // Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/BasePageRenderer.java // enum BasePagePosition { // HEAD, // NAVBAR_BUTTON, // FOOTER, // } // Path: src/main/java/com/indeed/proctor/webapp/tags/RenderBasePageInjectionTemplatesHandler.java import com.indeed.proctor.webapp.db.Environment; import com.indeed.proctor.webapp.extensions.renderer.BasePageRenderer; import com.indeed.proctor.webapp.extensions.renderer.BasePageRenderer.BasePagePosition; import org.apache.log4j.Logger; import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; import javax.servlet.ServletContext; import javax.servlet.jsp.tagext.TagSupport; import java.io.IOException; import java.util.Map; package com.indeed.proctor.webapp.tags; /** */ public class RenderBasePageInjectionTemplatesHandler extends TagSupport { private static final Logger LOGGER = Logger.getLogger(RenderBasePageInjectionTemplatesHandler.class);
private BasePagePosition position;
indeedeng/proctor-webapp-library
src/main/java/com/indeed/proctor/webapp/tags/RenderBasePageInjectionTemplatesHandler.java
// Path: src/main/java/com/indeed/proctor/webapp/db/Environment.java // public enum Environment { // WORKING("trunk", 0), // QA("qa", 1), // PRODUCTION("production", 2); // // private final String name; // private final int precedence; // private Environment(final String name, final int precedence) { // this.name = name; // this.precedence = precedence; // } // // public String getName() { // return name; // } // // public int getPrecedence() { // return precedence; // } // // private static final Map<String, Environment> LOOKUP = Maps.uniqueIndex(ImmutableList.copyOf(Environment.values()), Functions.toStringFunction()); // public static Environment fromName(String name) { // if(name == null) { // return null; // } else { // return LOOKUP.get(name.toLowerCase()); // } // } // // @Override // public String toString() { // return this.getName(); // } // } // // Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/BasePageRenderer.java // public interface BasePageRenderer { // enum BasePagePosition { // HEAD, // NAVBAR_BUTTON, // FOOTER, // } // // BasePagePosition getBasePagePosition(); // // @Deprecated // default String getRenderedHtml(final Environment branch) { // return ""; // } // // default String getRenderedHtml(final PageContext pageContext, final Environment branch) { // return ""; // } // } // // Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/BasePageRenderer.java // enum BasePagePosition { // HEAD, // NAVBAR_BUTTON, // FOOTER, // }
import com.indeed.proctor.webapp.db.Environment; import com.indeed.proctor.webapp.extensions.renderer.BasePageRenderer; import com.indeed.proctor.webapp.extensions.renderer.BasePageRenderer.BasePagePosition; import org.apache.log4j.Logger; import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; import javax.servlet.ServletContext; import javax.servlet.jsp.tagext.TagSupport; import java.io.IOException; import java.util.Map;
package com.indeed.proctor.webapp.tags; /** */ public class RenderBasePageInjectionTemplatesHandler extends TagSupport { private static final Logger LOGGER = Logger.getLogger(RenderBasePageInjectionTemplatesHandler.class); private BasePagePosition position;
// Path: src/main/java/com/indeed/proctor/webapp/db/Environment.java // public enum Environment { // WORKING("trunk", 0), // QA("qa", 1), // PRODUCTION("production", 2); // // private final String name; // private final int precedence; // private Environment(final String name, final int precedence) { // this.name = name; // this.precedence = precedence; // } // // public String getName() { // return name; // } // // public int getPrecedence() { // return precedence; // } // // private static final Map<String, Environment> LOOKUP = Maps.uniqueIndex(ImmutableList.copyOf(Environment.values()), Functions.toStringFunction()); // public static Environment fromName(String name) { // if(name == null) { // return null; // } else { // return LOOKUP.get(name.toLowerCase()); // } // } // // @Override // public String toString() { // return this.getName(); // } // } // // Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/BasePageRenderer.java // public interface BasePageRenderer { // enum BasePagePosition { // HEAD, // NAVBAR_BUTTON, // FOOTER, // } // // BasePagePosition getBasePagePosition(); // // @Deprecated // default String getRenderedHtml(final Environment branch) { // return ""; // } // // default String getRenderedHtml(final PageContext pageContext, final Environment branch) { // return ""; // } // } // // Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/BasePageRenderer.java // enum BasePagePosition { // HEAD, // NAVBAR_BUTTON, // FOOTER, // } // Path: src/main/java/com/indeed/proctor/webapp/tags/RenderBasePageInjectionTemplatesHandler.java import com.indeed.proctor.webapp.db.Environment; import com.indeed.proctor.webapp.extensions.renderer.BasePageRenderer; import com.indeed.proctor.webapp.extensions.renderer.BasePageRenderer.BasePagePosition; import org.apache.log4j.Logger; import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; import javax.servlet.ServletContext; import javax.servlet.jsp.tagext.TagSupport; import java.io.IOException; import java.util.Map; package com.indeed.proctor.webapp.tags; /** */ public class RenderBasePageInjectionTemplatesHandler extends TagSupport { private static final Logger LOGGER = Logger.getLogger(RenderBasePageInjectionTemplatesHandler.class); private BasePagePosition position;
private Environment branch;
indeedeng/proctor-webapp-library
src/main/java/com/indeed/proctor/webapp/tags/RenderBasePageInjectionTemplatesHandler.java
// Path: src/main/java/com/indeed/proctor/webapp/db/Environment.java // public enum Environment { // WORKING("trunk", 0), // QA("qa", 1), // PRODUCTION("production", 2); // // private final String name; // private final int precedence; // private Environment(final String name, final int precedence) { // this.name = name; // this.precedence = precedence; // } // // public String getName() { // return name; // } // // public int getPrecedence() { // return precedence; // } // // private static final Map<String, Environment> LOOKUP = Maps.uniqueIndex(ImmutableList.copyOf(Environment.values()), Functions.toStringFunction()); // public static Environment fromName(String name) { // if(name == null) { // return null; // } else { // return LOOKUP.get(name.toLowerCase()); // } // } // // @Override // public String toString() { // return this.getName(); // } // } // // Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/BasePageRenderer.java // public interface BasePageRenderer { // enum BasePagePosition { // HEAD, // NAVBAR_BUTTON, // FOOTER, // } // // BasePagePosition getBasePagePosition(); // // @Deprecated // default String getRenderedHtml(final Environment branch) { // return ""; // } // // default String getRenderedHtml(final PageContext pageContext, final Environment branch) { // return ""; // } // } // // Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/BasePageRenderer.java // enum BasePagePosition { // HEAD, // NAVBAR_BUTTON, // FOOTER, // }
import com.indeed.proctor.webapp.db.Environment; import com.indeed.proctor.webapp.extensions.renderer.BasePageRenderer; import com.indeed.proctor.webapp.extensions.renderer.BasePageRenderer.BasePagePosition; import org.apache.log4j.Logger; import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; import javax.servlet.ServletContext; import javax.servlet.jsp.tagext.TagSupport; import java.io.IOException; import java.util.Map;
package com.indeed.proctor.webapp.tags; /** */ public class RenderBasePageInjectionTemplatesHandler extends TagSupport { private static final Logger LOGGER = Logger.getLogger(RenderBasePageInjectionTemplatesHandler.class); private BasePagePosition position; private Environment branch;
// Path: src/main/java/com/indeed/proctor/webapp/db/Environment.java // public enum Environment { // WORKING("trunk", 0), // QA("qa", 1), // PRODUCTION("production", 2); // // private final String name; // private final int precedence; // private Environment(final String name, final int precedence) { // this.name = name; // this.precedence = precedence; // } // // public String getName() { // return name; // } // // public int getPrecedence() { // return precedence; // } // // private static final Map<String, Environment> LOOKUP = Maps.uniqueIndex(ImmutableList.copyOf(Environment.values()), Functions.toStringFunction()); // public static Environment fromName(String name) { // if(name == null) { // return null; // } else { // return LOOKUP.get(name.toLowerCase()); // } // } // // @Override // public String toString() { // return this.getName(); // } // } // // Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/BasePageRenderer.java // public interface BasePageRenderer { // enum BasePagePosition { // HEAD, // NAVBAR_BUTTON, // FOOTER, // } // // BasePagePosition getBasePagePosition(); // // @Deprecated // default String getRenderedHtml(final Environment branch) { // return ""; // } // // default String getRenderedHtml(final PageContext pageContext, final Environment branch) { // return ""; // } // } // // Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/BasePageRenderer.java // enum BasePagePosition { // HEAD, // NAVBAR_BUTTON, // FOOTER, // } // Path: src/main/java/com/indeed/proctor/webapp/tags/RenderBasePageInjectionTemplatesHandler.java import com.indeed.proctor.webapp.db.Environment; import com.indeed.proctor.webapp.extensions.renderer.BasePageRenderer; import com.indeed.proctor.webapp.extensions.renderer.BasePageRenderer.BasePagePosition; import org.apache.log4j.Logger; import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; import javax.servlet.ServletContext; import javax.servlet.jsp.tagext.TagSupport; import java.io.IOException; import java.util.Map; package com.indeed.proctor.webapp.tags; /** */ public class RenderBasePageInjectionTemplatesHandler extends TagSupport { private static final Logger LOGGER = Logger.getLogger(RenderBasePageInjectionTemplatesHandler.class); private BasePagePosition position; private Environment branch;
public void setPosition(final BasePageRenderer.BasePagePosition position) {
indeedeng/proctor-webapp-library
src/main/java/com/indeed/proctor/webapp/tags/RenderMatrixListPageInjectionTemplatesHandler.java
// Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/MatrixListPageRenderer.java // public interface MatrixListPageRenderer { // enum MatrixListPagePosition { // TOP, // LINK, // BOTTOM // } // // MatrixListPagePosition getMatrixListPagePosition(); // // @Deprecated // default String getRenderedHtml(final String testName, final TestMatrixVersion testMatrixVersion, final TestDefinition testDefinition){ // return ""; // } // // default String getRenderedHtml(final PageContext pageContext, final String testName, final TestMatrixVersion testMatrixVersion, final TestDefinition testDefinition){ // return ""; // } // } // // Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/MatrixListPageRenderer.java // enum MatrixListPagePosition { // TOP, // LINK, // BOTTOM // }
import com.indeed.proctor.common.model.TestDefinition; import com.indeed.proctor.common.model.TestMatrixVersion; import com.indeed.proctor.webapp.extensions.renderer.MatrixListPageRenderer; import com.indeed.proctor.webapp.extensions.renderer.MatrixListPageRenderer.MatrixListPagePosition; import org.apache.log4j.Logger; import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; import javax.servlet.ServletContext; import javax.servlet.jsp.tagext.TagSupport; import java.io.IOException; import java.util.Map;
package com.indeed.proctor.webapp.tags; /** */ public class RenderMatrixListPageInjectionTemplatesHandler extends TagSupport { private static final Logger LOGGER = Logger.getLogger(RenderMatrixListPageInjectionTemplatesHandler.class);
// Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/MatrixListPageRenderer.java // public interface MatrixListPageRenderer { // enum MatrixListPagePosition { // TOP, // LINK, // BOTTOM // } // // MatrixListPagePosition getMatrixListPagePosition(); // // @Deprecated // default String getRenderedHtml(final String testName, final TestMatrixVersion testMatrixVersion, final TestDefinition testDefinition){ // return ""; // } // // default String getRenderedHtml(final PageContext pageContext, final String testName, final TestMatrixVersion testMatrixVersion, final TestDefinition testDefinition){ // return ""; // } // } // // Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/MatrixListPageRenderer.java // enum MatrixListPagePosition { // TOP, // LINK, // BOTTOM // } // Path: src/main/java/com/indeed/proctor/webapp/tags/RenderMatrixListPageInjectionTemplatesHandler.java import com.indeed.proctor.common.model.TestDefinition; import com.indeed.proctor.common.model.TestMatrixVersion; import com.indeed.proctor.webapp.extensions.renderer.MatrixListPageRenderer; import com.indeed.proctor.webapp.extensions.renderer.MatrixListPageRenderer.MatrixListPagePosition; import org.apache.log4j.Logger; import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; import javax.servlet.ServletContext; import javax.servlet.jsp.tagext.TagSupport; import java.io.IOException; import java.util.Map; package com.indeed.proctor.webapp.tags; /** */ public class RenderMatrixListPageInjectionTemplatesHandler extends TagSupport { private static final Logger LOGGER = Logger.getLogger(RenderMatrixListPageInjectionTemplatesHandler.class);
private MatrixListPagePosition position;
indeedeng/proctor-webapp-library
src/main/java/com/indeed/proctor/webapp/tags/RenderMatrixListPageInjectionTemplatesHandler.java
// Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/MatrixListPageRenderer.java // public interface MatrixListPageRenderer { // enum MatrixListPagePosition { // TOP, // LINK, // BOTTOM // } // // MatrixListPagePosition getMatrixListPagePosition(); // // @Deprecated // default String getRenderedHtml(final String testName, final TestMatrixVersion testMatrixVersion, final TestDefinition testDefinition){ // return ""; // } // // default String getRenderedHtml(final PageContext pageContext, final String testName, final TestMatrixVersion testMatrixVersion, final TestDefinition testDefinition){ // return ""; // } // } // // Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/MatrixListPageRenderer.java // enum MatrixListPagePosition { // TOP, // LINK, // BOTTOM // }
import com.indeed.proctor.common.model.TestDefinition; import com.indeed.proctor.common.model.TestMatrixVersion; import com.indeed.proctor.webapp.extensions.renderer.MatrixListPageRenderer; import com.indeed.proctor.webapp.extensions.renderer.MatrixListPageRenderer.MatrixListPagePosition; import org.apache.log4j.Logger; import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; import javax.servlet.ServletContext; import javax.servlet.jsp.tagext.TagSupport; import java.io.IOException; import java.util.Map;
this.position = position; } public void setTestName(final String testName) { this.testName = testName; } public void setTestMatrixVersion(final TestMatrixVersion testMatrixVersion) { this.testMatrixVersion = testMatrixVersion; } public void setTestDefinition(final TestDefinition testDefinition) { this.testDefinition = testDefinition; } public int doStartTag() { try { pageContext.getOut().print(renderTemplates()); } catch (IOException e) { LOGGER.error("Failed to write rendered html to page context", e); } return SKIP_BODY; } private String renderTemplates() { final StringBuilder renderedHTML = new StringBuilder(); final ServletContext servletContext = pageContext.getServletContext(); final WebApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext); try {
// Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/MatrixListPageRenderer.java // public interface MatrixListPageRenderer { // enum MatrixListPagePosition { // TOP, // LINK, // BOTTOM // } // // MatrixListPagePosition getMatrixListPagePosition(); // // @Deprecated // default String getRenderedHtml(final String testName, final TestMatrixVersion testMatrixVersion, final TestDefinition testDefinition){ // return ""; // } // // default String getRenderedHtml(final PageContext pageContext, final String testName, final TestMatrixVersion testMatrixVersion, final TestDefinition testDefinition){ // return ""; // } // } // // Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/MatrixListPageRenderer.java // enum MatrixListPagePosition { // TOP, // LINK, // BOTTOM // } // Path: src/main/java/com/indeed/proctor/webapp/tags/RenderMatrixListPageInjectionTemplatesHandler.java import com.indeed.proctor.common.model.TestDefinition; import com.indeed.proctor.common.model.TestMatrixVersion; import com.indeed.proctor.webapp.extensions.renderer.MatrixListPageRenderer; import com.indeed.proctor.webapp.extensions.renderer.MatrixListPageRenderer.MatrixListPagePosition; import org.apache.log4j.Logger; import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; import javax.servlet.ServletContext; import javax.servlet.jsp.tagext.TagSupport; import java.io.IOException; import java.util.Map; this.position = position; } public void setTestName(final String testName) { this.testName = testName; } public void setTestMatrixVersion(final TestMatrixVersion testMatrixVersion) { this.testMatrixVersion = testMatrixVersion; } public void setTestDefinition(final TestDefinition testDefinition) { this.testDefinition = testDefinition; } public int doStartTag() { try { pageContext.getOut().print(renderTemplates()); } catch (IOException e) { LOGGER.error("Failed to write rendered html to page context", e); } return SKIP_BODY; } private String renderTemplates() { final StringBuilder renderedHTML = new StringBuilder(); final ServletContext servletContext = pageContext.getServletContext(); final WebApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext); try {
final Map<String, MatrixListPageRenderer> rendererBeans = BeanFactoryUtils.beansOfTypeIncludingAncestors(context, MatrixListPageRenderer.class);
indeedeng/proctor-webapp-library
src/main/java/com/indeed/proctor/webapp/tags/FormatCommitMessageDisplayTagHandler.java
// Path: src/main/java/com/indeed/proctor/webapp/extensions/CommitMessageDisplayFormatter.java // public interface CommitMessageDisplayFormatter { // public String formatMessage(String commitMessage); // }
import com.indeed.proctor.webapp.extensions.CommitMessageDisplayFormatter; import org.apache.commons.lang.StringEscapeUtils; import org.apache.log4j.Logger; import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; import javax.servlet.ServletContext; import javax.servlet.jsp.tagext.TagSupport; import java.io.IOException; import java.util.Map;
package com.indeed.proctor.webapp.tags; /** */ public class FormatCommitMessageDisplayTagHandler extends TagSupport { private static final Logger LOGGER = Logger.getLogger(FormatCommitMessageDisplayTagHandler.class); private String commitMessage; public void setCommitMessage(final String commitMessage) { this.commitMessage = commitMessage; } public int doStartTag() { try { pageContext.getOut().print(formatMessage(commitMessage)); } catch (IOException e) { LOGGER.error("Failed to write formatted commit message to page context", e); } return SKIP_BODY; } public String formatMessage(final String commitMessage) { final ServletContext servletContext = pageContext.getServletContext(); final WebApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext); try {
// Path: src/main/java/com/indeed/proctor/webapp/extensions/CommitMessageDisplayFormatter.java // public interface CommitMessageDisplayFormatter { // public String formatMessage(String commitMessage); // } // Path: src/main/java/com/indeed/proctor/webapp/tags/FormatCommitMessageDisplayTagHandler.java import com.indeed.proctor.webapp.extensions.CommitMessageDisplayFormatter; import org.apache.commons.lang.StringEscapeUtils; import org.apache.log4j.Logger; import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; import javax.servlet.ServletContext; import javax.servlet.jsp.tagext.TagSupport; import java.io.IOException; import java.util.Map; package com.indeed.proctor.webapp.tags; /** */ public class FormatCommitMessageDisplayTagHandler extends TagSupport { private static final Logger LOGGER = Logger.getLogger(FormatCommitMessageDisplayTagHandler.class); private String commitMessage; public void setCommitMessage(final String commitMessage) { this.commitMessage = commitMessage; } public int doStartTag() { try { pageContext.getOut().print(formatMessage(commitMessage)); } catch (IOException e) { LOGGER.error("Failed to write formatted commit message to page context", e); } return SKIP_BODY; } public String formatMessage(final String commitMessage) { final ServletContext servletContext = pageContext.getServletContext(); final WebApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext); try {
final Map<String, CommitMessageDisplayFormatter> formatterBeans = BeanFactoryUtils.beansOfTypeIncludingAncestors(context,CommitMessageDisplayFormatter.class);
indeedeng/proctor-webapp-library
src/main/java/com/indeed/proctor/webapp/tags/FormatDefinitionRevisionDisplayTagHandler.java
// Path: src/main/java/com/indeed/proctor/webapp/extensions/DefinitionRevisionDisplayFormatter.java // public interface DefinitionRevisionDisplayFormatter { // public String formatRevision(final Revision revision); // }
import com.indeed.proctor.store.Revision; import com.indeed.proctor.webapp.extensions.DefinitionRevisionDisplayFormatter; import org.apache.commons.lang.StringEscapeUtils; import org.apache.log4j.Logger; import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; import javax.servlet.ServletContext; import javax.servlet.jsp.tagext.TagSupport; import java.io.IOException; import java.util.Map;
package com.indeed.proctor.webapp.tags; /** */ public class FormatDefinitionRevisionDisplayTagHandler extends TagSupport { private static final Logger LOGGER = Logger.getLogger(FormatDefinitionRevisionDisplayTagHandler.class); private Revision revision; public void setRevision(final Revision revision) { this.revision = revision; } public int doStartTag() { try { pageContext.getOut().print(formatRevisionDisplay(revision)); } catch (IOException e) { LOGGER.error("Failed to write formatted revision to page context", e); } return SKIP_BODY; } public String formatRevisionDisplay(final Revision revision) { final String defaultFormattedRevision = revision.getAuthor() + " @ " + revision.getDate() + " (" + revision.getRevision() + ")"; final ServletContext servletContext = pageContext.getServletContext(); final WebApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext); try {
// Path: src/main/java/com/indeed/proctor/webapp/extensions/DefinitionRevisionDisplayFormatter.java // public interface DefinitionRevisionDisplayFormatter { // public String formatRevision(final Revision revision); // } // Path: src/main/java/com/indeed/proctor/webapp/tags/FormatDefinitionRevisionDisplayTagHandler.java import com.indeed.proctor.store.Revision; import com.indeed.proctor.webapp.extensions.DefinitionRevisionDisplayFormatter; import org.apache.commons.lang.StringEscapeUtils; import org.apache.log4j.Logger; import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; import javax.servlet.ServletContext; import javax.servlet.jsp.tagext.TagSupport; import java.io.IOException; import java.util.Map; package com.indeed.proctor.webapp.tags; /** */ public class FormatDefinitionRevisionDisplayTagHandler extends TagSupport { private static final Logger LOGGER = Logger.getLogger(FormatDefinitionRevisionDisplayTagHandler.class); private Revision revision; public void setRevision(final Revision revision) { this.revision = revision; } public int doStartTag() { try { pageContext.getOut().print(formatRevisionDisplay(revision)); } catch (IOException e) { LOGGER.error("Failed to write formatted revision to page context", e); } return SKIP_BODY; } public String formatRevisionDisplay(final Revision revision) { final String defaultFormattedRevision = revision.getAuthor() + " @ " + revision.getDate() + " (" + revision.getRevision() + ")"; final ServletContext servletContext = pageContext.getServletContext(); final WebApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext); try {
final Map<String, DefinitionRevisionDisplayFormatter> formatterBeans = BeanFactoryUtils.beansOfTypeIncludingAncestors(context,DefinitionRevisionDisplayFormatter.class);
indeedeng/proctor-webapp-library
src/main/java/com/indeed/proctor/webapp/jobs/AbstractJob.java
// Path: src/main/java/com/indeed/proctor/webapp/db/Environment.java // public enum Environment { // WORKING("trunk", 0), // QA("qa", 1), // PRODUCTION("production", 2); // // private final String name; // private final int precedence; // private Environment(final String name, final int precedence) { // this.name = name; // this.precedence = precedence; // } // // public String getName() { // return name; // } // // public int getPrecedence() { // return precedence; // } // // private static final Map<String, Environment> LOOKUP = Maps.uniqueIndex(ImmutableList.copyOf(Environment.values()), Functions.toStringFunction()); // public static Environment fromName(String name) { // if(name == null) { // return null; // } else { // return LOOKUP.get(name.toLowerCase()); // } // } // // @Override // public String toString() { // return this.getName(); // } // } // // Path: src/main/java/com/indeed/proctor/webapp/extensions/DefinitionChangeLog.java // public class DefinitionChangeLog { // private final List<String> log = new ArrayList<String>(); // private final List<Error> errors = new ArrayList<Error>(); // private final List<ResultUrl> urls = new ArrayList<ResultUrl>(); // // public void logMessage(final String message) { // log.add(message); // } // // public void addError(final Error error) { // if (error.getMessage() != null) { // log.add(error.getMessage()); // } // errors.add(error); // } // // public void addUrl(final String url, final String text ) { // this.addUrl(url, text, ""); // } // // public void addUrl(final String url, final String text, final String target ) { // this.addUrl(new ResultUrl(url, text, target)); // } // // public void addUrl(final ResultUrl url){ // urls.add(url); // } // // public List<ResultUrl> getUrls() { // if (!urls.isEmpty()) { // return urls; // } // return null; // } // // public List<String> getLog() { // if (!log.isEmpty()) { // return log; // } // return null; // } // // public List<Error> getErrors() { // if (!errors.isEmpty()) { // return errors; // } // return null; // } // // public boolean isErrorsFound(){ // return !errors.isEmpty(); // } // }
import com.google.common.base.CharMatcher; import com.google.common.base.Strings; import com.google.common.collect.ImmutableMap; import com.indeed.proctor.store.ProctorStore; import com.indeed.proctor.webapp.db.Environment; import com.indeed.proctor.webapp.extensions.DefinitionChangeLog; import java.util.List; import java.util.Map;
package com.indeed.proctor.webapp.jobs; public abstract class AbstractJob { private final Map<Environment, ProctorStore> stores; public AbstractJob(final ProctorStore trunkStore, final ProctorStore qaStore, final ProctorStore productionStore) { this.stores = ImmutableMap.of( Environment.WORKING, trunkStore, Environment.QA, qaStore, Environment.PRODUCTION, productionStore ); } protected static void validateUsernamePassword(final String username, final String password) throws IllegalArgumentException { if (CharMatcher.WHITESPACE.matchesAllOf(Strings.nullToEmpty(username)) || CharMatcher.WHITESPACE.matchesAllOf(Strings.nullToEmpty(password))) { throw new IllegalArgumentException("No username or password provided"); } } protected static void validateComment(final String comment) throws IllegalArgumentException { if (CharMatcher.WHITESPACE.matchesAllOf(Strings.nullToEmpty(comment))) { throw new IllegalArgumentException("Comment is required."); } }
// Path: src/main/java/com/indeed/proctor/webapp/db/Environment.java // public enum Environment { // WORKING("trunk", 0), // QA("qa", 1), // PRODUCTION("production", 2); // // private final String name; // private final int precedence; // private Environment(final String name, final int precedence) { // this.name = name; // this.precedence = precedence; // } // // public String getName() { // return name; // } // // public int getPrecedence() { // return precedence; // } // // private static final Map<String, Environment> LOOKUP = Maps.uniqueIndex(ImmutableList.copyOf(Environment.values()), Functions.toStringFunction()); // public static Environment fromName(String name) { // if(name == null) { // return null; // } else { // return LOOKUP.get(name.toLowerCase()); // } // } // // @Override // public String toString() { // return this.getName(); // } // } // // Path: src/main/java/com/indeed/proctor/webapp/extensions/DefinitionChangeLog.java // public class DefinitionChangeLog { // private final List<String> log = new ArrayList<String>(); // private final List<Error> errors = new ArrayList<Error>(); // private final List<ResultUrl> urls = new ArrayList<ResultUrl>(); // // public void logMessage(final String message) { // log.add(message); // } // // public void addError(final Error error) { // if (error.getMessage() != null) { // log.add(error.getMessage()); // } // errors.add(error); // } // // public void addUrl(final String url, final String text ) { // this.addUrl(url, text, ""); // } // // public void addUrl(final String url, final String text, final String target ) { // this.addUrl(new ResultUrl(url, text, target)); // } // // public void addUrl(final ResultUrl url){ // urls.add(url); // } // // public List<ResultUrl> getUrls() { // if (!urls.isEmpty()) { // return urls; // } // return null; // } // // public List<String> getLog() { // if (!log.isEmpty()) { // return log; // } // return null; // } // // public List<Error> getErrors() { // if (!errors.isEmpty()) { // return errors; // } // return null; // } // // public boolean isErrorsFound(){ // return !errors.isEmpty(); // } // } // Path: src/main/java/com/indeed/proctor/webapp/jobs/AbstractJob.java import com.google.common.base.CharMatcher; import com.google.common.base.Strings; import com.google.common.collect.ImmutableMap; import com.indeed.proctor.store.ProctorStore; import com.indeed.proctor.webapp.db.Environment; import com.indeed.proctor.webapp.extensions.DefinitionChangeLog; import java.util.List; import java.util.Map; package com.indeed.proctor.webapp.jobs; public abstract class AbstractJob { private final Map<Environment, ProctorStore> stores; public AbstractJob(final ProctorStore trunkStore, final ProctorStore qaStore, final ProctorStore productionStore) { this.stores = ImmutableMap.of( Environment.WORKING, trunkStore, Environment.QA, qaStore, Environment.PRODUCTION, productionStore ); } protected static void validateUsernamePassword(final String username, final String password) throws IllegalArgumentException { if (CharMatcher.WHITESPACE.matchesAllOf(Strings.nullToEmpty(username)) || CharMatcher.WHITESPACE.matchesAllOf(Strings.nullToEmpty(password))) { throw new IllegalArgumentException("No username or password provided"); } } protected static void validateComment(final String comment) throws IllegalArgumentException { if (CharMatcher.WHITESPACE.matchesAllOf(Strings.nullToEmpty(comment))) { throw new IllegalArgumentException("Comment is required."); } }
protected static void logDefinitionChangeLog(final DefinitionChangeLog definitionChangeLog, final String changeName, BackgroundJob backgroundJob) {
indeedeng/proctor-webapp-library
src/main/java/com/indeed/proctor/store/async/AsyncProctorStore.java
// Path: src/main/java/com/indeed/proctor/webapp/db/StoreFactory.java // public interface StoreFactory { // public ProctorStore createStore(final String relativePath) throws ConfigurationException; // }
import com.indeed.proctor.common.model.TestDefinition; import com.indeed.proctor.common.model.TestMatrixVersion; import com.indeed.proctor.store.ProctorStore; import com.indeed.proctor.store.Revision; import com.indeed.proctor.store.StoreException; import com.indeed.proctor.webapp.db.StoreFactory; import org.apache.commons.configuration.ConfigurationException; import org.apache.log4j.Logger; import java.io.IOException; import java.util.List; import java.util.Map; import java.util.concurrent.Callable; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors;
package com.indeed.proctor.store.async; public class AsyncProctorStore implements ProctorStore { private static final Logger LOGGER = Logger.getLogger(AsyncProctorStore.class); private volatile ProctorStore proctorStore = null; private static final ExecutorService executorService = Executors.newCachedThreadPool();
// Path: src/main/java/com/indeed/proctor/webapp/db/StoreFactory.java // public interface StoreFactory { // public ProctorStore createStore(final String relativePath) throws ConfigurationException; // } // Path: src/main/java/com/indeed/proctor/store/async/AsyncProctorStore.java import com.indeed.proctor.common.model.TestDefinition; import com.indeed.proctor.common.model.TestMatrixVersion; import com.indeed.proctor.store.ProctorStore; import com.indeed.proctor.store.Revision; import com.indeed.proctor.store.StoreException; import com.indeed.proctor.webapp.db.StoreFactory; import org.apache.commons.configuration.ConfigurationException; import org.apache.log4j.Logger; import java.io.IOException; import java.util.List; import java.util.Map; import java.util.concurrent.Callable; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; package com.indeed.proctor.store.async; public class AsyncProctorStore implements ProctorStore { private static final Logger LOGGER = Logger.getLogger(AsyncProctorStore.class); private volatile ProctorStore proctorStore = null; private static final ExecutorService executorService = Executors.newCachedThreadPool();
public AsyncProctorStore(final StoreFactory factory, final String relativePath) {
indeedeng/proctor-webapp-library
src/test/java/com/indeed/proctor/webapp/controllers/TestProctorController.java
// Path: src/main/java/com/indeed/proctor/webapp/db/Environment.java // public enum Environment { // WORKING("trunk", 0), // QA("qa", 1), // PRODUCTION("production", 2); // // private final String name; // private final int precedence; // private Environment(final String name, final int precedence) { // this.name = name; // this.precedence = precedence; // } // // public String getName() { // return name; // } // // public int getPrecedence() { // return precedence; // } // // private static final Map<String, Environment> LOOKUP = Maps.uniqueIndex(ImmutableList.copyOf(Environment.values()), Functions.toStringFunction()); // public static Environment fromName(String name) { // if(name == null) { // return null; // } else { // return LOOKUP.get(name.toLowerCase()); // } // } // // @Override // public String toString() { // return this.getName(); // } // } // // Path: src/main/java/com/indeed/proctor/webapp/model/AppVersion.java // public class AppVersion implements Comparable<AppVersion> { // private final String app; // private final String version; // // public AppVersion(final String app, // final String version) { // this.app = app; // this.version = version; // } // // @Override // public boolean equals(final Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // final AppVersion that = (AppVersion) o; // // if (!app.equals(that.app)) { // return false; // } // if (!version.equals(that.version)) { // return false; // } // // return true; // } // // @Override // public int hashCode() { // int result = app.hashCode(); // result = 31 * result + version.hashCode(); // return result; // } // // @Override // public int compareTo(AppVersion that) { // if (this == that) { // return 0; // } // return ComparisonChain.start() // .compare(app, that.app) // .compare(version, that.version) // .result(); // } // // public String getApp() { // return app; // } // // public String getVersion() { // return version; // } // // @Override // public String toString() { // return app + '@' + version; // } // // public String toShortString() { // final String shortVersionName = version.length() > 7 ? version.substring(0, 7) : version; // return app + '@' + shortVersionName; // } // }
import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.indeed.proctor.common.PayloadSpecification; import com.indeed.proctor.common.ProctorUtils; import com.indeed.proctor.common.TestSpecification; import com.indeed.proctor.common.model.Allocation; import com.indeed.proctor.common.model.Audit; import com.indeed.proctor.common.model.ConsumableTestDefinition; import com.indeed.proctor.common.model.Payload; import com.indeed.proctor.common.model.Range; import com.indeed.proctor.common.model.TestBucket; import com.indeed.proctor.common.model.TestDefinition; import com.indeed.proctor.common.model.TestMatrixArtifact; import com.indeed.proctor.common.model.TestType; import com.indeed.proctor.webapp.db.Environment; import com.indeed.proctor.webapp.model.AppVersion; import org.apache.commons.lang.StringUtils; import org.junit.Test; import java.util.Collections; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue;
) ), "#A1" ) ), false, Collections.emptyMap(), Collections.emptyMap(), "test for a unit test" ) ); artifact.setTests(ImmutableMap.of(TEST_NAME, testDefinition)); return artifact; } @Test public void testCompatibleSpecificationResultFromRequiredTest() { final TestSpecification testSpecification = new TestSpecification(); testSpecification.setFallbackValue(-1); final PayloadSpecification payloadSpecification = new PayloadSpecification(); payloadSpecification.setType("longValue"); testSpecification.setPayload(payloadSpecification); testSpecification.setBuckets( ImmutableMap.of( "inactive", -1, "control", 0 ) );
// Path: src/main/java/com/indeed/proctor/webapp/db/Environment.java // public enum Environment { // WORKING("trunk", 0), // QA("qa", 1), // PRODUCTION("production", 2); // // private final String name; // private final int precedence; // private Environment(final String name, final int precedence) { // this.name = name; // this.precedence = precedence; // } // // public String getName() { // return name; // } // // public int getPrecedence() { // return precedence; // } // // private static final Map<String, Environment> LOOKUP = Maps.uniqueIndex(ImmutableList.copyOf(Environment.values()), Functions.toStringFunction()); // public static Environment fromName(String name) { // if(name == null) { // return null; // } else { // return LOOKUP.get(name.toLowerCase()); // } // } // // @Override // public String toString() { // return this.getName(); // } // } // // Path: src/main/java/com/indeed/proctor/webapp/model/AppVersion.java // public class AppVersion implements Comparable<AppVersion> { // private final String app; // private final String version; // // public AppVersion(final String app, // final String version) { // this.app = app; // this.version = version; // } // // @Override // public boolean equals(final Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // final AppVersion that = (AppVersion) o; // // if (!app.equals(that.app)) { // return false; // } // if (!version.equals(that.version)) { // return false; // } // // return true; // } // // @Override // public int hashCode() { // int result = app.hashCode(); // result = 31 * result + version.hashCode(); // return result; // } // // @Override // public int compareTo(AppVersion that) { // if (this == that) { // return 0; // } // return ComparisonChain.start() // .compare(app, that.app) // .compare(version, that.version) // .result(); // } // // public String getApp() { // return app; // } // // public String getVersion() { // return version; // } // // @Override // public String toString() { // return app + '@' + version; // } // // public String toShortString() { // final String shortVersionName = version.length() > 7 ? version.substring(0, 7) : version; // return app + '@' + shortVersionName; // } // } // Path: src/test/java/com/indeed/proctor/webapp/controllers/TestProctorController.java import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.indeed.proctor.common.PayloadSpecification; import com.indeed.proctor.common.ProctorUtils; import com.indeed.proctor.common.TestSpecification; import com.indeed.proctor.common.model.Allocation; import com.indeed.proctor.common.model.Audit; import com.indeed.proctor.common.model.ConsumableTestDefinition; import com.indeed.proctor.common.model.Payload; import com.indeed.proctor.common.model.Range; import com.indeed.proctor.common.model.TestBucket; import com.indeed.proctor.common.model.TestDefinition; import com.indeed.proctor.common.model.TestMatrixArtifact; import com.indeed.proctor.common.model.TestType; import com.indeed.proctor.webapp.db.Environment; import com.indeed.proctor.webapp.model.AppVersion; import org.apache.commons.lang.StringUtils; import org.junit.Test; import java.util.Collections; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; ) ), "#A1" ) ), false, Collections.emptyMap(), Collections.emptyMap(), "test for a unit test" ) ); artifact.setTests(ImmutableMap.of(TEST_NAME, testDefinition)); return artifact; } @Test public void testCompatibleSpecificationResultFromRequiredTest() { final TestSpecification testSpecification = new TestSpecification(); testSpecification.setFallbackValue(-1); final PayloadSpecification payloadSpecification = new PayloadSpecification(); payloadSpecification.setType("longValue"); testSpecification.setPayload(payloadSpecification); testSpecification.setBuckets( ImmutableMap.of( "inactive", -1, "control", 0 ) );
final AppVersion appVersion = new AppVersion("sample application", "v1");
indeedeng/proctor-webapp-library
src/test/java/com/indeed/proctor/webapp/controllers/TestProctorController.java
// Path: src/main/java/com/indeed/proctor/webapp/db/Environment.java // public enum Environment { // WORKING("trunk", 0), // QA("qa", 1), // PRODUCTION("production", 2); // // private final String name; // private final int precedence; // private Environment(final String name, final int precedence) { // this.name = name; // this.precedence = precedence; // } // // public String getName() { // return name; // } // // public int getPrecedence() { // return precedence; // } // // private static final Map<String, Environment> LOOKUP = Maps.uniqueIndex(ImmutableList.copyOf(Environment.values()), Functions.toStringFunction()); // public static Environment fromName(String name) { // if(name == null) { // return null; // } else { // return LOOKUP.get(name.toLowerCase()); // } // } // // @Override // public String toString() { // return this.getName(); // } // } // // Path: src/main/java/com/indeed/proctor/webapp/model/AppVersion.java // public class AppVersion implements Comparable<AppVersion> { // private final String app; // private final String version; // // public AppVersion(final String app, // final String version) { // this.app = app; // this.version = version; // } // // @Override // public boolean equals(final Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // final AppVersion that = (AppVersion) o; // // if (!app.equals(that.app)) { // return false; // } // if (!version.equals(that.version)) { // return false; // } // // return true; // } // // @Override // public int hashCode() { // int result = app.hashCode(); // result = 31 * result + version.hashCode(); // return result; // } // // @Override // public int compareTo(AppVersion that) { // if (this == that) { // return 0; // } // return ComparisonChain.start() // .compare(app, that.app) // .compare(version, that.version) // .result(); // } // // public String getApp() { // return app; // } // // public String getVersion() { // return version; // } // // @Override // public String toString() { // return app + '@' + version; // } // // public String toShortString() { // final String shortVersionName = version.length() > 7 ? version.substring(0, 7) : version; // return app + '@' + shortVersionName; // } // }
import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.indeed.proctor.common.PayloadSpecification; import com.indeed.proctor.common.ProctorUtils; import com.indeed.proctor.common.TestSpecification; import com.indeed.proctor.common.model.Allocation; import com.indeed.proctor.common.model.Audit; import com.indeed.proctor.common.model.ConsumableTestDefinition; import com.indeed.proctor.common.model.Payload; import com.indeed.proctor.common.model.Range; import com.indeed.proctor.common.model.TestBucket; import com.indeed.proctor.common.model.TestDefinition; import com.indeed.proctor.common.model.TestMatrixArtifact; import com.indeed.proctor.common.model.TestType; import com.indeed.proctor.webapp.db.Environment; import com.indeed.proctor.webapp.model.AppVersion; import org.apache.commons.lang.StringUtils; import org.junit.Test; import java.util.Collections; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue;
) ), false, Collections.emptyMap(), Collections.emptyMap(), "test for a unit test" ) ); artifact.setTests(ImmutableMap.of(TEST_NAME, testDefinition)); return artifact; } @Test public void testCompatibleSpecificationResultFromRequiredTest() { final TestSpecification testSpecification = new TestSpecification(); testSpecification.setFallbackValue(-1); final PayloadSpecification payloadSpecification = new PayloadSpecification(); payloadSpecification.setType("longValue"); testSpecification.setPayload(payloadSpecification); testSpecification.setBuckets( ImmutableMap.of( "inactive", -1, "control", 0 ) ); final AppVersion appVersion = new AppVersion("sample application", "v1"); final ProctorController.CompatibleSpecificationResult result = ProctorController.CompatibleSpecificationResult.fromRequiredTest(
// Path: src/main/java/com/indeed/proctor/webapp/db/Environment.java // public enum Environment { // WORKING("trunk", 0), // QA("qa", 1), // PRODUCTION("production", 2); // // private final String name; // private final int precedence; // private Environment(final String name, final int precedence) { // this.name = name; // this.precedence = precedence; // } // // public String getName() { // return name; // } // // public int getPrecedence() { // return precedence; // } // // private static final Map<String, Environment> LOOKUP = Maps.uniqueIndex(ImmutableList.copyOf(Environment.values()), Functions.toStringFunction()); // public static Environment fromName(String name) { // if(name == null) { // return null; // } else { // return LOOKUP.get(name.toLowerCase()); // } // } // // @Override // public String toString() { // return this.getName(); // } // } // // Path: src/main/java/com/indeed/proctor/webapp/model/AppVersion.java // public class AppVersion implements Comparable<AppVersion> { // private final String app; // private final String version; // // public AppVersion(final String app, // final String version) { // this.app = app; // this.version = version; // } // // @Override // public boolean equals(final Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // final AppVersion that = (AppVersion) o; // // if (!app.equals(that.app)) { // return false; // } // if (!version.equals(that.version)) { // return false; // } // // return true; // } // // @Override // public int hashCode() { // int result = app.hashCode(); // result = 31 * result + version.hashCode(); // return result; // } // // @Override // public int compareTo(AppVersion that) { // if (this == that) { // return 0; // } // return ComparisonChain.start() // .compare(app, that.app) // .compare(version, that.version) // .result(); // } // // public String getApp() { // return app; // } // // public String getVersion() { // return version; // } // // @Override // public String toString() { // return app + '@' + version; // } // // public String toShortString() { // final String shortVersionName = version.length() > 7 ? version.substring(0, 7) : version; // return app + '@' + shortVersionName; // } // } // Path: src/test/java/com/indeed/proctor/webapp/controllers/TestProctorController.java import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.indeed.proctor.common.PayloadSpecification; import com.indeed.proctor.common.ProctorUtils; import com.indeed.proctor.common.TestSpecification; import com.indeed.proctor.common.model.Allocation; import com.indeed.proctor.common.model.Audit; import com.indeed.proctor.common.model.ConsumableTestDefinition; import com.indeed.proctor.common.model.Payload; import com.indeed.proctor.common.model.Range; import com.indeed.proctor.common.model.TestBucket; import com.indeed.proctor.common.model.TestDefinition; import com.indeed.proctor.common.model.TestMatrixArtifact; import com.indeed.proctor.common.model.TestType; import com.indeed.proctor.webapp.db.Environment; import com.indeed.proctor.webapp.model.AppVersion; import org.apache.commons.lang.StringUtils; import org.junit.Test; import java.util.Collections; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; ) ), false, Collections.emptyMap(), Collections.emptyMap(), "test for a unit test" ) ); artifact.setTests(ImmutableMap.of(TEST_NAME, testDefinition)); return artifact; } @Test public void testCompatibleSpecificationResultFromRequiredTest() { final TestSpecification testSpecification = new TestSpecification(); testSpecification.setFallbackValue(-1); final PayloadSpecification payloadSpecification = new PayloadSpecification(); payloadSpecification.setType("longValue"); testSpecification.setPayload(payloadSpecification); testSpecification.setBuckets( ImmutableMap.of( "inactive", -1, "control", 0 ) ); final AppVersion appVersion = new AppVersion("sample application", "v1"); final ProctorController.CompatibleSpecificationResult result = ProctorController.CompatibleSpecificationResult.fromRequiredTest(
Environment.PRODUCTION,
indeedeng/proctor-webapp-library
src/main/java/com/indeed/proctor/webapp/util/spring/ThreadFactoryBean.java
// Path: src/main/java/com/indeed/proctor/webapp/util/threads/LogOnUncaughtExceptionHandler.java // public class LogOnUncaughtExceptionHandler implements UncaughtExceptionHandler { // private Logger logger = Logger.getLogger(LogOnUncaughtExceptionHandler.class); // // public LogOnUncaughtExceptionHandler(){} // // // public LogOnUncaughtExceptionHandler(final Logger logger) { // this.logger = logger; // } // // public void setLogger(final Logger logger) { // this.logger = logger; // } // // @Override // public void uncaughtException(final Thread t, final Throwable e) { // logger.error("Uncaught throwable in thread " + t.getName() + "/" + t.getId(), e); // } // }
import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.indeed.proctor.webapp.util.threads.LogOnUncaughtExceptionHandler; import org.springframework.beans.factory.FactoryBean; import java.util.concurrent.ThreadFactory;
package com.indeed.proctor.webapp.util.spring; /** */ public class ThreadFactoryBean implements FactoryBean<ThreadFactory> { private String nameFormat; @Override public ThreadFactory getObject() throws Exception { return new ThreadFactoryBuilder() .setNameFormat(this.nameFormat)
// Path: src/main/java/com/indeed/proctor/webapp/util/threads/LogOnUncaughtExceptionHandler.java // public class LogOnUncaughtExceptionHandler implements UncaughtExceptionHandler { // private Logger logger = Logger.getLogger(LogOnUncaughtExceptionHandler.class); // // public LogOnUncaughtExceptionHandler(){} // // // public LogOnUncaughtExceptionHandler(final Logger logger) { // this.logger = logger; // } // // public void setLogger(final Logger logger) { // this.logger = logger; // } // // @Override // public void uncaughtException(final Thread t, final Throwable e) { // logger.error("Uncaught throwable in thread " + t.getName() + "/" + t.getId(), e); // } // } // Path: src/main/java/com/indeed/proctor/webapp/util/spring/ThreadFactoryBean.java import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.indeed.proctor.webapp.util.threads.LogOnUncaughtExceptionHandler; import org.springframework.beans.factory.FactoryBean; import java.util.concurrent.ThreadFactory; package com.indeed.proctor.webapp.util.spring; /** */ public class ThreadFactoryBean implements FactoryBean<ThreadFactory> { private String nameFormat; @Override public ThreadFactory getObject() throws Exception { return new ThreadFactoryBuilder() .setNameFormat(this.nameFormat)
.setUncaughtExceptionHandler(new LogOnUncaughtExceptionHandler())
indeedeng/proctor-webapp-library
src/main/java/com/indeed/proctor/webapp/tags/RenderDefinitionHistoryPageInjectionTemplatesHandler.java
// Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/DefinitionHistoryPageRenderer.java // public interface DefinitionHistoryPageRenderer { // enum DefinitionHistoryPagePosition { // PROMOTE_FORM_BOTTOM, // } // // DefinitionHistoryPagePosition getDefinitionHistoryPagePositionPosition(); // // @Deprecated // default String getRenderedHtml(final String testName, final Revision testDefinitionVersion){ // return ""; // } // // default String getRenderedHtml(final PageContext pageContext, final String testName, final Revision testDefinitionVersion){ // return ""; // } // } // // Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/DefinitionHistoryPageRenderer.java // enum DefinitionHistoryPagePosition { // PROMOTE_FORM_BOTTOM, // }
import com.indeed.proctor.store.Revision; import com.indeed.proctor.webapp.extensions.renderer.DefinitionHistoryPageRenderer; import com.indeed.proctor.webapp.extensions.renderer.DefinitionHistoryPageRenderer.DefinitionHistoryPagePosition; import org.apache.log4j.Logger; import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; import javax.servlet.ServletContext; import javax.servlet.jsp.tagext.TagSupport; import java.io.IOException; import java.util.Map;
package com.indeed.proctor.webapp.tags; /** */ public class RenderDefinitionHistoryPageInjectionTemplatesHandler extends TagSupport { private static final Logger LOGGER = Logger.getLogger(RenderDefinitionHistoryPageInjectionTemplatesHandler.class);
// Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/DefinitionHistoryPageRenderer.java // public interface DefinitionHistoryPageRenderer { // enum DefinitionHistoryPagePosition { // PROMOTE_FORM_BOTTOM, // } // // DefinitionHistoryPagePosition getDefinitionHistoryPagePositionPosition(); // // @Deprecated // default String getRenderedHtml(final String testName, final Revision testDefinitionVersion){ // return ""; // } // // default String getRenderedHtml(final PageContext pageContext, final String testName, final Revision testDefinitionVersion){ // return ""; // } // } // // Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/DefinitionHistoryPageRenderer.java // enum DefinitionHistoryPagePosition { // PROMOTE_FORM_BOTTOM, // } // Path: src/main/java/com/indeed/proctor/webapp/tags/RenderDefinitionHistoryPageInjectionTemplatesHandler.java import com.indeed.proctor.store.Revision; import com.indeed.proctor.webapp.extensions.renderer.DefinitionHistoryPageRenderer; import com.indeed.proctor.webapp.extensions.renderer.DefinitionHistoryPageRenderer.DefinitionHistoryPagePosition; import org.apache.log4j.Logger; import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; import javax.servlet.ServletContext; import javax.servlet.jsp.tagext.TagSupport; import java.io.IOException; import java.util.Map; package com.indeed.proctor.webapp.tags; /** */ public class RenderDefinitionHistoryPageInjectionTemplatesHandler extends TagSupport { private static final Logger LOGGER = Logger.getLogger(RenderDefinitionHistoryPageInjectionTemplatesHandler.class);
private DefinitionHistoryPagePosition position;
indeedeng/proctor-webapp-library
src/main/java/com/indeed/proctor/webapp/tags/RenderDefinitionHistoryPageInjectionTemplatesHandler.java
// Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/DefinitionHistoryPageRenderer.java // public interface DefinitionHistoryPageRenderer { // enum DefinitionHistoryPagePosition { // PROMOTE_FORM_BOTTOM, // } // // DefinitionHistoryPagePosition getDefinitionHistoryPagePositionPosition(); // // @Deprecated // default String getRenderedHtml(final String testName, final Revision testDefinitionVersion){ // return ""; // } // // default String getRenderedHtml(final PageContext pageContext, final String testName, final Revision testDefinitionVersion){ // return ""; // } // } // // Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/DefinitionHistoryPageRenderer.java // enum DefinitionHistoryPagePosition { // PROMOTE_FORM_BOTTOM, // }
import com.indeed.proctor.store.Revision; import com.indeed.proctor.webapp.extensions.renderer.DefinitionHistoryPageRenderer; import com.indeed.proctor.webapp.extensions.renderer.DefinitionHistoryPageRenderer.DefinitionHistoryPagePosition; import org.apache.log4j.Logger; import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; import javax.servlet.ServletContext; import javax.servlet.jsp.tagext.TagSupport; import java.io.IOException; import java.util.Map;
package com.indeed.proctor.webapp.tags; /** */ public class RenderDefinitionHistoryPageInjectionTemplatesHandler extends TagSupport { private static final Logger LOGGER = Logger.getLogger(RenderDefinitionHistoryPageInjectionTemplatesHandler.class); private DefinitionHistoryPagePosition position; private String testName; private Revision testDefinitionVersion; public void setPosition(final DefinitionHistoryPagePosition position) { this.position = position; } public void setTestName(final String testName) { this.testName = testName; } public void setTestDefinitionVersion(final Revision testDefinitionVersion) { this.testDefinitionVersion = testDefinitionVersion; } public int doStartTag() { try { pageContext.getOut().print(renderTemplates()); } catch (IOException e) { LOGGER.error("Failed to write rendered html to page context", e); } return SKIP_BODY; } private String renderTemplates() { final StringBuilder renderedHTML = new StringBuilder(); final ServletContext servletContext = pageContext.getServletContext(); final WebApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext); try {
// Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/DefinitionHistoryPageRenderer.java // public interface DefinitionHistoryPageRenderer { // enum DefinitionHistoryPagePosition { // PROMOTE_FORM_BOTTOM, // } // // DefinitionHistoryPagePosition getDefinitionHistoryPagePositionPosition(); // // @Deprecated // default String getRenderedHtml(final String testName, final Revision testDefinitionVersion){ // return ""; // } // // default String getRenderedHtml(final PageContext pageContext, final String testName, final Revision testDefinitionVersion){ // return ""; // } // } // // Path: src/main/java/com/indeed/proctor/webapp/extensions/renderer/DefinitionHistoryPageRenderer.java // enum DefinitionHistoryPagePosition { // PROMOTE_FORM_BOTTOM, // } // Path: src/main/java/com/indeed/proctor/webapp/tags/RenderDefinitionHistoryPageInjectionTemplatesHandler.java import com.indeed.proctor.store.Revision; import com.indeed.proctor.webapp.extensions.renderer.DefinitionHistoryPageRenderer; import com.indeed.proctor.webapp.extensions.renderer.DefinitionHistoryPageRenderer.DefinitionHistoryPagePosition; import org.apache.log4j.Logger; import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; import javax.servlet.ServletContext; import javax.servlet.jsp.tagext.TagSupport; import java.io.IOException; import java.util.Map; package com.indeed.proctor.webapp.tags; /** */ public class RenderDefinitionHistoryPageInjectionTemplatesHandler extends TagSupport { private static final Logger LOGGER = Logger.getLogger(RenderDefinitionHistoryPageInjectionTemplatesHandler.class); private DefinitionHistoryPagePosition position; private String testName; private Revision testDefinitionVersion; public void setPosition(final DefinitionHistoryPagePosition position) { this.position = position; } public void setTestName(final String testName) { this.testName = testName; } public void setTestDefinitionVersion(final Revision testDefinitionVersion) { this.testDefinitionVersion = testDefinitionVersion; } public int doStartTag() { try { pageContext.getOut().print(renderTemplates()); } catch (IOException e) { LOGGER.error("Failed to write rendered html to page context", e); } return SKIP_BODY; } private String renderTemplates() { final StringBuilder renderedHTML = new StringBuilder(); final ServletContext servletContext = pageContext.getServletContext(); final WebApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext); try {
final Map<String, DefinitionHistoryPageRenderer> rendererBeans = BeanFactoryUtils.beansOfTypeIncludingAncestors(context, DefinitionHistoryPageRenderer.class);
jkrasnay/sqlbuilder
src/test/java/ca/krasnay/sqlbuilder/orm/MappingTest.java
// Path: src/main/java/ca/krasnay/sqlbuilder/PostgresqlDialect.java // public class PostgresqlDialect implements Dialect, Serializable { // // private static final long serialVersionUID = 1; // // public String createCountSelect(String sql) { // return "select count(*) from (" + sql + ") a"; // } // // public String createPageSelect(String sql, int limit, int offset) { // return String.format("%s limit %d offset %d", sql, limit, offset); // } // // @Override // public Supplier<Integer> getSequence(DataSource dataSource, String sequenceName) { // return new PostgresqlSequence(dataSource, sequenceName); // } // }
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import junit.framework.TestCase; import org.h2.jdbcx.JdbcDataSource; import org.springframework.jdbc.core.JdbcTemplate; import ca.krasnay.sqlbuilder.PostgresqlDialect;
package ca.krasnay.sqlbuilder.orm; public class MappingTest extends TestCase { public static class Employee { private int id; private int version; private String name; } public void testAll() throws Exception { Class.forName("org.h2.Driver"); JdbcDataSource ds = new JdbcDataSource(); ds.setURL("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1"); JdbcTemplate t = new JdbcTemplate(ds); t.update("create table Employee (id int primary key, version int not null, name varchar(255))"); t.update("create sequence myseq start with 1");
// Path: src/main/java/ca/krasnay/sqlbuilder/PostgresqlDialect.java // public class PostgresqlDialect implements Dialect, Serializable { // // private static final long serialVersionUID = 1; // // public String createCountSelect(String sql) { // return "select count(*) from (" + sql + ") a"; // } // // public String createPageSelect(String sql, int limit, int offset) { // return String.format("%s limit %d offset %d", sql, limit, offset); // } // // @Override // public Supplier<Integer> getSequence(DataSource dataSource, String sequenceName) { // return new PostgresqlSequence(dataSource, sequenceName); // } // } // Path: src/test/java/ca/krasnay/sqlbuilder/orm/MappingTest.java import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import junit.framework.TestCase; import org.h2.jdbcx.JdbcDataSource; import org.springframework.jdbc.core.JdbcTemplate; import ca.krasnay.sqlbuilder.PostgresqlDialect; package ca.krasnay.sqlbuilder.orm; public class MappingTest extends TestCase { public static class Employee { private int id; private int version; private String name; } public void testAll() throws Exception { Class.forName("org.h2.Driver"); JdbcDataSource ds = new JdbcDataSource(); ds.setURL("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1"); JdbcTemplate t = new JdbcTemplate(ds); t.update("create table Employee (id int primary key, version int not null, name varchar(255))"); t.update("create sequence myseq start with 1");
OrmConfig ormConfig = new OrmConfig(ds, new PostgresqlDialect());
jkrasnay/sqlbuilder
src/main/java/ca/krasnay/sqlbuilder/orm/OrmConfig.java
// Path: src/main/java/ca/krasnay/sqlbuilder/Dialect.java // public interface Dialect { // // /** // * Returns a SQL statement that returns the number of rows that would be // * returned by another select. // * // * @param sql // * Inner select statement, i.e. the one that returns the rows // * themselves. // */ // public String createCountSelect(String sql); // // /** // * Returns a SQL statement that returns a limited number of rows from an // * inner query. Note that the inner select should include an ORDER BY clause // * that strictly orders the result set; otherwise, some database servers may // * return pages inconsistently. // * // * @param sql // * Inner query that would return the full result set. // * @param limit // * Maximum number of rows to return. // * @param offset // * Index into the result set of the first row returned. // */ // public String createPageSelect(String sql, int limit, int offset); // // /** // * Returns an integer supplier representing a database sequence. // * // * @param dataSource // * DataSource where the sequence exists. // * @param sequenceName // * Name of the sequence. // */ // public Supplier<Integer> getSequence(DataSource dataSource, String sequenceName); // // } // // Path: src/main/java/ca/krasnay/sqlbuilder/Supplier.java // public interface Supplier<T> { // // public T get(); // // }
import javax.sql.DataSource; import ca.krasnay.sqlbuilder.Dialect; import ca.krasnay.sqlbuilder.Supplier;
package ca.krasnay.sqlbuilder.orm; /** * Configuration of the ORM system. Each mapping must be constructed with one of * these objects. * * @author <a href="mailto:john@krasnay.ca">John Krasnay</a> */ public class OrmConfig { private DataSource dataSource;
// Path: src/main/java/ca/krasnay/sqlbuilder/Dialect.java // public interface Dialect { // // /** // * Returns a SQL statement that returns the number of rows that would be // * returned by another select. // * // * @param sql // * Inner select statement, i.e. the one that returns the rows // * themselves. // */ // public String createCountSelect(String sql); // // /** // * Returns a SQL statement that returns a limited number of rows from an // * inner query. Note that the inner select should include an ORDER BY clause // * that strictly orders the result set; otherwise, some database servers may // * return pages inconsistently. // * // * @param sql // * Inner query that would return the full result set. // * @param limit // * Maximum number of rows to return. // * @param offset // * Index into the result set of the first row returned. // */ // public String createPageSelect(String sql, int limit, int offset); // // /** // * Returns an integer supplier representing a database sequence. // * // * @param dataSource // * DataSource where the sequence exists. // * @param sequenceName // * Name of the sequence. // */ // public Supplier<Integer> getSequence(DataSource dataSource, String sequenceName); // // } // // Path: src/main/java/ca/krasnay/sqlbuilder/Supplier.java // public interface Supplier<T> { // // public T get(); // // } // Path: src/main/java/ca/krasnay/sqlbuilder/orm/OrmConfig.java import javax.sql.DataSource; import ca.krasnay.sqlbuilder.Dialect; import ca.krasnay.sqlbuilder.Supplier; package ca.krasnay.sqlbuilder.orm; /** * Configuration of the ORM system. Each mapping must be constructed with one of * these objects. * * @author <a href="mailto:john@krasnay.ca">John Krasnay</a> */ public class OrmConfig { private DataSource dataSource;
private Dialect dialect;
jkrasnay/sqlbuilder
src/main/java/ca/krasnay/sqlbuilder/orm/OrmConfig.java
// Path: src/main/java/ca/krasnay/sqlbuilder/Dialect.java // public interface Dialect { // // /** // * Returns a SQL statement that returns the number of rows that would be // * returned by another select. // * // * @param sql // * Inner select statement, i.e. the one that returns the rows // * themselves. // */ // public String createCountSelect(String sql); // // /** // * Returns a SQL statement that returns a limited number of rows from an // * inner query. Note that the inner select should include an ORDER BY clause // * that strictly orders the result set; otherwise, some database servers may // * return pages inconsistently. // * // * @param sql // * Inner query that would return the full result set. // * @param limit // * Maximum number of rows to return. // * @param offset // * Index into the result set of the first row returned. // */ // public String createPageSelect(String sql, int limit, int offset); // // /** // * Returns an integer supplier representing a database sequence. // * // * @param dataSource // * DataSource where the sequence exists. // * @param sequenceName // * Name of the sequence. // */ // public Supplier<Integer> getSequence(DataSource dataSource, String sequenceName); // // } // // Path: src/main/java/ca/krasnay/sqlbuilder/Supplier.java // public interface Supplier<T> { // // public T get(); // // }
import javax.sql.DataSource; import ca.krasnay.sqlbuilder.Dialect; import ca.krasnay.sqlbuilder.Supplier;
package ca.krasnay.sqlbuilder.orm; /** * Configuration of the ORM system. Each mapping must be constructed with one of * these objects. * * @author <a href="mailto:john@krasnay.ca">John Krasnay</a> */ public class OrmConfig { private DataSource dataSource; private Dialect dialect; private ConverterFactory converterFactory = new DefaultConverterFactory(); public OrmConfig(DataSource dataSource, Dialect dialect) { super(); this.dataSource = dataSource; this.dialect = dialect; } public ConverterFactory getConverterFactory() { return converterFactory; } public DataSource getDataSource() { return dataSource; } public Dialect getDialect() { return dialect; }
// Path: src/main/java/ca/krasnay/sqlbuilder/Dialect.java // public interface Dialect { // // /** // * Returns a SQL statement that returns the number of rows that would be // * returned by another select. // * // * @param sql // * Inner select statement, i.e. the one that returns the rows // * themselves. // */ // public String createCountSelect(String sql); // // /** // * Returns a SQL statement that returns a limited number of rows from an // * inner query. Note that the inner select should include an ORDER BY clause // * that strictly orders the result set; otherwise, some database servers may // * return pages inconsistently. // * // * @param sql // * Inner query that would return the full result set. // * @param limit // * Maximum number of rows to return. // * @param offset // * Index into the result set of the first row returned. // */ // public String createPageSelect(String sql, int limit, int offset); // // /** // * Returns an integer supplier representing a database sequence. // * // * @param dataSource // * DataSource where the sequence exists. // * @param sequenceName // * Name of the sequence. // */ // public Supplier<Integer> getSequence(DataSource dataSource, String sequenceName); // // } // // Path: src/main/java/ca/krasnay/sqlbuilder/Supplier.java // public interface Supplier<T> { // // public T get(); // // } // Path: src/main/java/ca/krasnay/sqlbuilder/orm/OrmConfig.java import javax.sql.DataSource; import ca.krasnay.sqlbuilder.Dialect; import ca.krasnay.sqlbuilder.Supplier; package ca.krasnay.sqlbuilder.orm; /** * Configuration of the ORM system. Each mapping must be constructed with one of * these objects. * * @author <a href="mailto:john@krasnay.ca">John Krasnay</a> */ public class OrmConfig { private DataSource dataSource; private Dialect dialect; private ConverterFactory converterFactory = new DefaultConverterFactory(); public OrmConfig(DataSource dataSource, Dialect dialect) { super(); this.dataSource = dataSource; this.dialect = dialect; } public ConverterFactory getConverterFactory() { return converterFactory; } public DataSource getDataSource() { return dataSource; } public Dialect getDialect() { return dialect; }
public Supplier<Integer> getSequence(String sequenceName) {
jkrasnay/sqlbuilder
src/test/java/ca/krasnay/sqlbuilder/ParameterizedPreparedStatementCreatorTest.java
// Path: src/main/java/ca/krasnay/sqlbuilder/ParameterizedPreparedStatementCreator.java // static class SqlAndParams { // // private String sql; // private List<Object> params; // // private SqlAndParams(String sql, List<Object> params) { // super(); // this.sql = sql; // this.params = params; // } // // public List<Object> getParams() { // return params; // } // // public String getSql() { // return sql; // } // }
import junit.framework.TestCase; import ca.krasnay.sqlbuilder.ParameterizedPreparedStatementCreator.SqlAndParams;
package ca.krasnay.sqlbuilder; public class ParameterizedPreparedStatementCreatorTest extends TestCase { private void assertResult(ParameterizedPreparedStatementCreator ppsc, String psSql, Object... params) {
// Path: src/main/java/ca/krasnay/sqlbuilder/ParameterizedPreparedStatementCreator.java // static class SqlAndParams { // // private String sql; // private List<Object> params; // // private SqlAndParams(String sql, List<Object> params) { // super(); // this.sql = sql; // this.params = params; // } // // public List<Object> getParams() { // return params; // } // // public String getSql() { // return sql; // } // } // Path: src/test/java/ca/krasnay/sqlbuilder/ParameterizedPreparedStatementCreatorTest.java import junit.framework.TestCase; import ca.krasnay.sqlbuilder.ParameterizedPreparedStatementCreator.SqlAndParams; package ca.krasnay.sqlbuilder; public class ParameterizedPreparedStatementCreatorTest extends TestCase { private void assertResult(ParameterizedPreparedStatementCreator ppsc, String psSql, Object... params) {
SqlAndParams sap = ppsc.createSqlAndParams();
peshkira/c3po
c3po-api/src/main/java/com/petpet/c3po/api/model/helper/MetadataRecord.java
// Path: c3po-api/src/main/java/com/petpet/c3po/api/model/Property.java // public class Property implements Model { // // /** // * The id of the proeprty. // */ // private String id; // // /** // * The key of the property. // */ // private String key; // // /** // * The type of the property. // */ // private String type; // // /** // * A default constructor. // */ // public Property() { // // } // // /** // * Creates a property with the given key as key and id and sets the type to a // * string. // * // * @param key // * the key of the property. // */ // public Property(String key) { // this.id = key; // this.key = key; // this.type = PropertyType.STRING.name(); // } // // /** // * Creates a property with the given key as key and id and sets the type to // * the given type. // * // * @param key // * @param type // */ // public Property(String key, PropertyType type) { // this( key ); // this.type = type.name(); // } // // public void setId( String id ) { // this.id = id; // } // // public String getId() { // return this.id; // } // // public String getKey() { // return key; // } // // public void setKey( String key ) { // this.key = key; // } // // public String getType() { // return type; // } // // public void setType( String type ) { // this.type = type; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + ((id == null) ? 0 : id.hashCode()); // result = prime * result + ((key == null) ? 0 : key.hashCode()); // result = prime * result + ((type == null) ? 0 : type.hashCode()); // return result; // } // // @Override // public boolean equals( Object obj ) { // if ( this == obj ) // return true; // if ( obj == null ) // return false; // if ( getClass() != obj.getClass() ) // return false; // Property other = (Property) obj; // if ( id == null ) { // if ( other.id != null ) // return false; // } else if ( !id.equals( other.id ) ) // return false; // if ( key == null ) { // if ( other.key != null ) // return false; // } else if ( !key.equals( other.key ) ) // return false; // if ( type == null ) { // if ( other.type != null ) // return false; // } else if ( !type.equals( other.type ) ) // return false; // return true; // } // // }
import java.util.ArrayList; import java.util.List; import com.petpet.c3po.api.model.Property;
/******************************************************************************* * Copyright 2013 Petar Petrov <me@petarpetrov.org> * * 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 com.petpet.c3po.api.model.helper; /** * A single metadata record of an element. * * @author Petar Petrov <me@petarpetrov.org> * */ public class MetadataRecord { /** * The status of the element shows the certainty with which the value for the * given property is correct. * * @author Petar Petrov <me@petarpetrov.org> * */ public static enum Status { /** * Means that more than one tools confirm the value. */ OK, /** * Only one tool has given this value. */ SINGLE_RESULT, /** * One, two or more tools have provided different values for the same * property. */ CONFLICT } /** * The property to which the value of this record belongs. */
// Path: c3po-api/src/main/java/com/petpet/c3po/api/model/Property.java // public class Property implements Model { // // /** // * The id of the proeprty. // */ // private String id; // // /** // * The key of the property. // */ // private String key; // // /** // * The type of the property. // */ // private String type; // // /** // * A default constructor. // */ // public Property() { // // } // // /** // * Creates a property with the given key as key and id and sets the type to a // * string. // * // * @param key // * the key of the property. // */ // public Property(String key) { // this.id = key; // this.key = key; // this.type = PropertyType.STRING.name(); // } // // /** // * Creates a property with the given key as key and id and sets the type to // * the given type. // * // * @param key // * @param type // */ // public Property(String key, PropertyType type) { // this( key ); // this.type = type.name(); // } // // public void setId( String id ) { // this.id = id; // } // // public String getId() { // return this.id; // } // // public String getKey() { // return key; // } // // public void setKey( String key ) { // this.key = key; // } // // public String getType() { // return type; // } // // public void setType( String type ) { // this.type = type; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + ((id == null) ? 0 : id.hashCode()); // result = prime * result + ((key == null) ? 0 : key.hashCode()); // result = prime * result + ((type == null) ? 0 : type.hashCode()); // return result; // } // // @Override // public boolean equals( Object obj ) { // if ( this == obj ) // return true; // if ( obj == null ) // return false; // if ( getClass() != obj.getClass() ) // return false; // Property other = (Property) obj; // if ( id == null ) { // if ( other.id != null ) // return false; // } else if ( !id.equals( other.id ) ) // return false; // if ( key == null ) { // if ( other.key != null ) // return false; // } else if ( !key.equals( other.key ) ) // return false; // if ( type == null ) { // if ( other.type != null ) // return false; // } else if ( !type.equals( other.type ) ) // return false; // return true; // } // // } // Path: c3po-api/src/main/java/com/petpet/c3po/api/model/helper/MetadataRecord.java import java.util.ArrayList; import java.util.List; import com.petpet.c3po.api.model.Property; /******************************************************************************* * Copyright 2013 Petar Petrov <me@petarpetrov.org> * * 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 com.petpet.c3po.api.model.helper; /** * A single metadata record of an element. * * @author Petar Petrov <me@petarpetrov.org> * */ public class MetadataRecord { /** * The status of the element shows the certainty with which the value for the * given property is correct. * * @author Petar Petrov <me@petarpetrov.org> * */ public static enum Status { /** * Means that more than one tools confirm the value. */ OK, /** * Only one tool has given this value. */ SINGLE_RESULT, /** * One, two or more tools have provided different values for the same * property. */ CONFLICT } /** * The property to which the value of this record belongs. */
private Property property;
peshkira/c3po
c3po-cmd/src/main/java/com/petpet/c3po/parameters/GatherParams.java
// Path: c3po-cmd/src/main/java/com/petpet/c3po/command/GatherCommand.java // public class GatherCommand extends AbstractCLICommand implements Command { // // /** // * Default logger. // */ // private static final Logger LOG = LoggerFactory.getLogger( GatherCommand.class ); // // /** // * The gathering params passed on the command line. // */ // private GatherParams params; // // /** // * Creates a controller and submits a process meta data request. // */ // @Override // public void execute() { // LOG.info( "Starting meta data gathering command." ); // long start = System.currentTimeMillis(); // // final Configurator configurator = Configurator.getDefaultConfigurator(); // configurator.configure(); // // final Map<String, String> conf = new HashMap<String, String>(); // conf.put( Constants.OPT_COLLECTION_LOCATION, this.params.getLocation() ); // conf.put( Constants.OPT_COLLECTION_NAME, this.params.getCollection() ); // conf.put( Constants.OPT_INPUT_TYPE, this.params.getType() ); // conf.put( Constants.OPT_RECURSIVE, this.params.isRecursive() + "" ); // // final Controller ctrl = new Controller( configurator ); // try { // ctrl.processMetaData( conf ); // System.out.println( "I finished translating the data. I am fluent in over six million forms of communication." ); // System.out.println( "I finished memorizing all the data." ); // } catch ( C3POConfigurationException e ) { // LOG.error( e.getMessage() ); // System.err.println("An error occurred: " + e.getMessage()); // return; // // } finally { // cleanup(); // } // // long end = System.currentTimeMillis(); // this.setTime( end - start ); // } // // @Override // public void setParams( Params params ) { // if ( params != null && params instanceof GatherParams ) { // this.params = (GatherParams) params; // } // } // // } // // Path: c3po-cmd/src/main/java/com/petpet/c3po/parameters/validation/InputTypeValidator.java // public class InputTypeValidator implements IValueValidator<String> { // // /** // * The supported metadata types. // */ // private static final String[] SUPPORTED_METADATA = { "FITS", "TIKA" }; // // /** // * @throws ParameterException // * if the passed value is not supported. // */ // @Override // public void validate( String name, String value ) throws ParameterException { // if ( !Arrays.asList( SUPPORTED_METADATA ).contains( value ) ) { // throw new ParameterException( "Input type '" + value + "' is not supported. Please use one of " // + Arrays.deepToString( SUPPORTED_METADATA ) ); // } // // } // // }
import com.beust.jcommander.Parameter; import com.petpet.c3po.command.GatherCommand; import com.petpet.c3po.parameters.validation.InputTypeValidator;
/******************************************************************************* * Copyright 2013 Petar Petrov <me@petarpetrov.org> * * 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 com.petpet.c3po.parameters; /** * The supported parameters for the {@link GatherCommand} * * @author Petar Petrov <me@petarpetrov.org> * */ public class GatherParams implements Params { /** * The collection under which to store the gathered data - required. Supports * '-c' and '--collection'. */ @Parameter( names = { "-c", "--collection" }, description = "The name of the collection", required = true ) private String collection; /** * The input directory, where the meta data is stored - required. Supports * '-i' and '--inputdir'. */ @Parameter( names = { "-i", "--inputdir" }, description = "The input directory where the meta data is stored", required = true ) private String location; /** * If the flag is present, then the gathering process will traverse the input * dir recursively. Default is false. Supports '-r' and '--recursive'. */ @Parameter( names = { "-r", "--recursive" }, arity = 0, description = "Whether or not to gather recursively" ) private boolean recursive = false; /** * The type of meta data that will be gathered. Default is 'FITS' Supports * '-t' and '--type'. */
// Path: c3po-cmd/src/main/java/com/petpet/c3po/command/GatherCommand.java // public class GatherCommand extends AbstractCLICommand implements Command { // // /** // * Default logger. // */ // private static final Logger LOG = LoggerFactory.getLogger( GatherCommand.class ); // // /** // * The gathering params passed on the command line. // */ // private GatherParams params; // // /** // * Creates a controller and submits a process meta data request. // */ // @Override // public void execute() { // LOG.info( "Starting meta data gathering command." ); // long start = System.currentTimeMillis(); // // final Configurator configurator = Configurator.getDefaultConfigurator(); // configurator.configure(); // // final Map<String, String> conf = new HashMap<String, String>(); // conf.put( Constants.OPT_COLLECTION_LOCATION, this.params.getLocation() ); // conf.put( Constants.OPT_COLLECTION_NAME, this.params.getCollection() ); // conf.put( Constants.OPT_INPUT_TYPE, this.params.getType() ); // conf.put( Constants.OPT_RECURSIVE, this.params.isRecursive() + "" ); // // final Controller ctrl = new Controller( configurator ); // try { // ctrl.processMetaData( conf ); // System.out.println( "I finished translating the data. I am fluent in over six million forms of communication." ); // System.out.println( "I finished memorizing all the data." ); // } catch ( C3POConfigurationException e ) { // LOG.error( e.getMessage() ); // System.err.println("An error occurred: " + e.getMessage()); // return; // // } finally { // cleanup(); // } // // long end = System.currentTimeMillis(); // this.setTime( end - start ); // } // // @Override // public void setParams( Params params ) { // if ( params != null && params instanceof GatherParams ) { // this.params = (GatherParams) params; // } // } // // } // // Path: c3po-cmd/src/main/java/com/petpet/c3po/parameters/validation/InputTypeValidator.java // public class InputTypeValidator implements IValueValidator<String> { // // /** // * The supported metadata types. // */ // private static final String[] SUPPORTED_METADATA = { "FITS", "TIKA" }; // // /** // * @throws ParameterException // * if the passed value is not supported. // */ // @Override // public void validate( String name, String value ) throws ParameterException { // if ( !Arrays.asList( SUPPORTED_METADATA ).contains( value ) ) { // throw new ParameterException( "Input type '" + value + "' is not supported. Please use one of " // + Arrays.deepToString( SUPPORTED_METADATA ) ); // } // // } // // } // Path: c3po-cmd/src/main/java/com/petpet/c3po/parameters/GatherParams.java import com.beust.jcommander.Parameter; import com.petpet.c3po.command.GatherCommand; import com.petpet.c3po.parameters.validation.InputTypeValidator; /******************************************************************************* * Copyright 2013 Petar Petrov <me@petarpetrov.org> * * 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 com.petpet.c3po.parameters; /** * The supported parameters for the {@link GatherCommand} * * @author Petar Petrov <me@petarpetrov.org> * */ public class GatherParams implements Params { /** * The collection under which to store the gathered data - required. Supports * '-c' and '--collection'. */ @Parameter( names = { "-c", "--collection" }, description = "The name of the collection", required = true ) private String collection; /** * The input directory, where the meta data is stored - required. Supports * '-i' and '--inputdir'. */ @Parameter( names = { "-i", "--inputdir" }, description = "The input directory where the meta data is stored", required = true ) private String location; /** * If the flag is present, then the gathering process will traverse the input * dir recursively. Default is false. Supports '-r' and '--recursive'. */ @Parameter( names = { "-r", "--recursive" }, arity = 0, description = "Whether or not to gather recursively" ) private boolean recursive = false; /** * The type of meta data that will be gathered. Default is 'FITS' Supports * '-t' and '--type'. */
@Parameter( names = { "-t", "--type" }, arity = 1, validateValueWith = InputTypeValidator.class, description = "Optional parameter to define the meta data type. Use one of 'FITS' or 'TIKA', to select the type of the input files. Default is FITS" )
peshkira/c3po
c3po-api/src/main/java/com/petpet/c3po/api/model/Element.java
// Path: c3po-api/src/main/java/com/petpet/c3po/api/model/helper/MetadataRecord.java // public class MetadataRecord { // // /** // * The status of the element shows the certainty with which the value for the // * given property is correct. // * // * @author Petar Petrov <me@petarpetrov.org> // * // */ // public static enum Status { // /** // * Means that more than one tools confirm the value. // */ // OK, // // /** // * Only one tool has given this value. // */ // SINGLE_RESULT, // // /** // * One, two or more tools have provided different values for the same // * property. // */ // CONFLICT // } // // /** // * The property to which the value of this record belongs. // */ // private Property property; // // /** // * The actual measured value. // */ // private String value; // // /** // * A list for the conflicting values; // */ // private List<String> values; // // /** // * The status of the value. // * // * @see Status // */ // private String status; // // /** // * A list of sources that have measured the value. // */ // private List<String> sources; // // /** // * Creates an empty record with a status ok. // */ // public MetadataRecord() { // this.sources = new ArrayList<String>(); // this.status = Status.OK.name(); // } // // /** // * Creates an record for the given property with the given value and a status // * SINGLE_RESULT. // * // * @param p // * @param value // */ // public MetadataRecord(Property p, String value) { // this(); // this.property = p; // this.value = value; // this.status = Status.SINGLE_RESULT.name(); // } // // /** // * Creates a record for the given property with the given value and the given // * status. // * // * @param p // * @param value // * @param status // */ // public MetadataRecord(Property p, String value, Status status) { // this( p, value ); // this.status = status.name(); // } // // public Property getProperty() { // return this.property; // } // // public void setProperty( Property p ) { // this.property = p; // } // // public String getValue() { // return value; // } // // public void setValue( String value ) { // this.value = value; // } // // public String getStatus() { // return status; // } // // public void setStatus( String status ) { // this.status = status; // } // // public List<String> getSources() { // return sources; // } // // public void setSources( List<String> sources ) { // this.sources = sources; // } // // public List<String> getValues() { // if ( values == null ) { // this.values = new ArrayList<String>(); // } // return values; // } // // public void setValues( List<String> values ) { // this.values = values; // } // // }
import java.util.ArrayList; import java.util.Iterator; import java.util.List; import com.petpet.c3po.api.model.helper.MetadataRecord;
/******************************************************************************* * Copyright 2013 Petar Petrov <me@petarpetrov.org> * * 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 com.petpet.c3po.api.model; /** * A domain object class that encapsulates a digital object and its meta data. * It consists of a couple of attributes that describe a simple object (usually * a file) and a list of specific metadata. * * @author Petar Petrov <me@petarpetrov.org> */ public class Element implements Model { /** * A back-end related identifier of this object. */ private String id; /** * The collection to which the current element belongs. */ private String collection; /** * Some non-unique name of this element. */ private String name; /** * Some unique identifier of this element that references the original file * back in the source. */ private String uid; /** * A list of {@link MetadataRecord} info. */
// Path: c3po-api/src/main/java/com/petpet/c3po/api/model/helper/MetadataRecord.java // public class MetadataRecord { // // /** // * The status of the element shows the certainty with which the value for the // * given property is correct. // * // * @author Petar Petrov <me@petarpetrov.org> // * // */ // public static enum Status { // /** // * Means that more than one tools confirm the value. // */ // OK, // // /** // * Only one tool has given this value. // */ // SINGLE_RESULT, // // /** // * One, two or more tools have provided different values for the same // * property. // */ // CONFLICT // } // // /** // * The property to which the value of this record belongs. // */ // private Property property; // // /** // * The actual measured value. // */ // private String value; // // /** // * A list for the conflicting values; // */ // private List<String> values; // // /** // * The status of the value. // * // * @see Status // */ // private String status; // // /** // * A list of sources that have measured the value. // */ // private List<String> sources; // // /** // * Creates an empty record with a status ok. // */ // public MetadataRecord() { // this.sources = new ArrayList<String>(); // this.status = Status.OK.name(); // } // // /** // * Creates an record for the given property with the given value and a status // * SINGLE_RESULT. // * // * @param p // * @param value // */ // public MetadataRecord(Property p, String value) { // this(); // this.property = p; // this.value = value; // this.status = Status.SINGLE_RESULT.name(); // } // // /** // * Creates a record for the given property with the given value and the given // * status. // * // * @param p // * @param value // * @param status // */ // public MetadataRecord(Property p, String value, Status status) { // this( p, value ); // this.status = status.name(); // } // // public Property getProperty() { // return this.property; // } // // public void setProperty( Property p ) { // this.property = p; // } // // public String getValue() { // return value; // } // // public void setValue( String value ) { // this.value = value; // } // // public String getStatus() { // return status; // } // // public void setStatus( String status ) { // this.status = status; // } // // public List<String> getSources() { // return sources; // } // // public void setSources( List<String> sources ) { // this.sources = sources; // } // // public List<String> getValues() { // if ( values == null ) { // this.values = new ArrayList<String>(); // } // return values; // } // // public void setValues( List<String> values ) { // this.values = values; // } // // } // Path: c3po-api/src/main/java/com/petpet/c3po/api/model/Element.java import java.util.ArrayList; import java.util.Iterator; import java.util.List; import com.petpet.c3po.api.model.helper.MetadataRecord; /******************************************************************************* * Copyright 2013 Petar Petrov <me@petarpetrov.org> * * 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 com.petpet.c3po.api.model; /** * A domain object class that encapsulates a digital object and its meta data. * It consists of a couple of attributes that describe a simple object (usually * a file) and a list of specific metadata. * * @author Petar Petrov <me@petarpetrov.org> */ public class Element implements Model { /** * A back-end related identifier of this object. */ private String id; /** * The collection to which the current element belongs. */ private String collection; /** * Some non-unique name of this element. */ private String name; /** * Some unique identifier of this element that references the original file * back in the source. */ private String uid; /** * A list of {@link MetadataRecord} info. */
private List<MetadataRecord> metadata;
peshkira/c3po
c3po-api/src/main/java/com/petpet/c3po/api/dao/ReadOnlyCache.java
// Path: c3po-api/src/main/java/com/petpet/c3po/api/model/Property.java // public class Property implements Model { // // /** // * The id of the proeprty. // */ // private String id; // // /** // * The key of the property. // */ // private String key; // // /** // * The type of the property. // */ // private String type; // // /** // * A default constructor. // */ // public Property() { // // } // // /** // * Creates a property with the given key as key and id and sets the type to a // * string. // * // * @param key // * the key of the property. // */ // public Property(String key) { // this.id = key; // this.key = key; // this.type = PropertyType.STRING.name(); // } // // /** // * Creates a property with the given key as key and id and sets the type to // * the given type. // * // * @param key // * @param type // */ // public Property(String key, PropertyType type) { // this( key ); // this.type = type.name(); // } // // public void setId( String id ) { // this.id = id; // } // // public String getId() { // return this.id; // } // // public String getKey() { // return key; // } // // public void setKey( String key ) { // this.key = key; // } // // public String getType() { // return type; // } // // public void setType( String type ) { // this.type = type; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + ((id == null) ? 0 : id.hashCode()); // result = prime * result + ((key == null) ? 0 : key.hashCode()); // result = prime * result + ((type == null) ? 0 : type.hashCode()); // return result; // } // // @Override // public boolean equals( Object obj ) { // if ( this == obj ) // return true; // if ( obj == null ) // return false; // if ( getClass() != obj.getClass() ) // return false; // Property other = (Property) obj; // if ( id == null ) { // if ( other.id != null ) // return false; // } else if ( !id.equals( other.id ) ) // return false; // if ( key == null ) { // if ( other.key != null ) // return false; // } else if ( !key.equals( other.key ) ) // return false; // if ( type == null ) { // if ( other.type != null ) // return false; // } else if ( !type.equals( other.type ) ) // return false; // return true; // } // // } // // Path: c3po-api/src/main/java/com/petpet/c3po/api/model/Source.java // public class Source implements Model { // // /** // * The id of the source. // */ // private String id; // // /** // * The name of the source. // */ // private String name; // // /** // * The version of the source. // */ // private String version; // // /** // * A default constructor. // */ // public Source() { // // } // // /** // * Creates a new source with the name and the version and auto generates an // * id. // * // * @param name // * the name of the source. // * @param version // * the version of the source. // */ // public Source(String name, String version) { // this.id = UUID.randomUUID().toString(); // this.name = name; // this.version = version; // } // // public String getId() { // return id; // } // // public void setId( String id ) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName( String name ) { // this.name = name; // } // // public String getVersion() { // return version; // } // // public void setVersion( String version ) { // this.version = version; // } // // }
import com.petpet.c3po.api.model.Property; import com.petpet.c3po.api.model.Source;
/******************************************************************************* * Copyright 2013 Petar Petrov <me@petarpetrov.org> * * 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 com.petpet.c3po.api.dao; /** * A simple Read Only cache for {@link Property}, {@link Source} and any kind of * other objects. * * @author Petar Petrov <me@petarpetrov.org> * */ public interface ReadOnlyCache { /** * Retrieves the property designated by the given key. Depending on the * implementation it might return null or a new property if there was no * property with the given key. * * @param key * the key to look for. * @return the cached property. */ Property getProperty( String key ); /** * Retrieves the source designated by the given name and version. Depending on * the implementation it might return null or a new source if there was no * source with the given name and version. * * @param name * the name of the source tool. * @param version * the version of the too. * @return */
// Path: c3po-api/src/main/java/com/petpet/c3po/api/model/Property.java // public class Property implements Model { // // /** // * The id of the proeprty. // */ // private String id; // // /** // * The key of the property. // */ // private String key; // // /** // * The type of the property. // */ // private String type; // // /** // * A default constructor. // */ // public Property() { // // } // // /** // * Creates a property with the given key as key and id and sets the type to a // * string. // * // * @param key // * the key of the property. // */ // public Property(String key) { // this.id = key; // this.key = key; // this.type = PropertyType.STRING.name(); // } // // /** // * Creates a property with the given key as key and id and sets the type to // * the given type. // * // * @param key // * @param type // */ // public Property(String key, PropertyType type) { // this( key ); // this.type = type.name(); // } // // public void setId( String id ) { // this.id = id; // } // // public String getId() { // return this.id; // } // // public String getKey() { // return key; // } // // public void setKey( String key ) { // this.key = key; // } // // public String getType() { // return type; // } // // public void setType( String type ) { // this.type = type; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + ((id == null) ? 0 : id.hashCode()); // result = prime * result + ((key == null) ? 0 : key.hashCode()); // result = prime * result + ((type == null) ? 0 : type.hashCode()); // return result; // } // // @Override // public boolean equals( Object obj ) { // if ( this == obj ) // return true; // if ( obj == null ) // return false; // if ( getClass() != obj.getClass() ) // return false; // Property other = (Property) obj; // if ( id == null ) { // if ( other.id != null ) // return false; // } else if ( !id.equals( other.id ) ) // return false; // if ( key == null ) { // if ( other.key != null ) // return false; // } else if ( !key.equals( other.key ) ) // return false; // if ( type == null ) { // if ( other.type != null ) // return false; // } else if ( !type.equals( other.type ) ) // return false; // return true; // } // // } // // Path: c3po-api/src/main/java/com/petpet/c3po/api/model/Source.java // public class Source implements Model { // // /** // * The id of the source. // */ // private String id; // // /** // * The name of the source. // */ // private String name; // // /** // * The version of the source. // */ // private String version; // // /** // * A default constructor. // */ // public Source() { // // } // // /** // * Creates a new source with the name and the version and auto generates an // * id. // * // * @param name // * the name of the source. // * @param version // * the version of the source. // */ // public Source(String name, String version) { // this.id = UUID.randomUUID().toString(); // this.name = name; // this.version = version; // } // // public String getId() { // return id; // } // // public void setId( String id ) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName( String name ) { // this.name = name; // } // // public String getVersion() { // return version; // } // // public void setVersion( String version ) { // this.version = version; // } // // } // Path: c3po-api/src/main/java/com/petpet/c3po/api/dao/ReadOnlyCache.java import com.petpet.c3po.api.model.Property; import com.petpet.c3po.api.model.Source; /******************************************************************************* * Copyright 2013 Petar Petrov <me@petarpetrov.org> * * 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 com.petpet.c3po.api.dao; /** * A simple Read Only cache for {@link Property}, {@link Source} and any kind of * other objects. * * @author Petar Petrov <me@petarpetrov.org> * */ public interface ReadOnlyCache { /** * Retrieves the property designated by the given key. Depending on the * implementation it might return null or a new property if there was no * property with the given key. * * @param key * the key to look for. * @return the cached property. */ Property getProperty( String key ); /** * Retrieves the source designated by the given name and version. Depending on * the implementation it might return null or a new source if there was no * source with the given name and version. * * @param name * the name of the source tool. * @param version * the version of the too. * @return */
Source getSource( String name, String version );
peshkira/c3po
c3po-core/src/main/java/com/petpet/c3po/adaptor/rules/AssignCollectionToElementRule.java
// Path: c3po-api/src/main/java/com/petpet/c3po/api/adaptor/PostProcessingRule.java // public interface PostProcessingRule extends ProcessingRule { // // /** // * This method does some processing over the passed element and returns it. It // * can do any kind of post processing to the element. // * // * @param e // * the element to process. // * @return the processed element. // */ // Element process( Element e ); // // } // // Path: c3po-api/src/main/java/com/petpet/c3po/api/model/Element.java // public class Element implements Model { // // /** // * A back-end related identifier of this object. // */ // private String id; // // /** // * The collection to which the current element belongs. // */ // private String collection; // // /** // * Some non-unique name of this element. // */ // private String name; // // /** // * Some unique identifier of this element that references the original file // * back in the source. // */ // private String uid; // // /** // * A list of {@link MetadataRecord} info. // */ // private List<MetadataRecord> metadata; // // /** // * Creates an element with the given uid and name. // * // * @param uid // * the unique identifier of this element. // * @param name // * the name of this element. // */ // public Element(String uid, String name) { // this.uid = uid; // this.name = name; // this.metadata = new ArrayList<MetadataRecord>(); // } // // /** // * Creates an element with the given uid, name and collection. // * // * @param collection // * @param uid // * @param name // */ // public Element(String collection, String uid, String name) { // this( uid, name ); // this.collection = collection; // } // // public String getCollection() { // return collection; // } // // public void setCollection( String collection ) { // this.collection = collection; // } // // public String getName() { // return name; // } // // public void setName( String name ) { // this.name = name; // } // // public String getUid() { // return uid; // } // // public void setUid( String uid ) { // this.uid = uid; // } // // public List<MetadataRecord> getMetadata() { // return metadata; // } // // public void setMetadata( List<MetadataRecord> metadata ) { // this.metadata = metadata; // } // // public String getId() { // return id; // } // // public void setId( String id ) { // this.id = id; // } // // /** // * Removes all records for the given property id and returns a list of all // * removed meta data records. // * // * @param property // * the id of the property // * @return returns the records of the element matching this property that were // * deleted. // */ // public List<MetadataRecord> removeMetadata( String property ) { // List<MetadataRecord> result = new ArrayList<MetadataRecord>(); // // Iterator<MetadataRecord> iterator = this.metadata.iterator(); // while ( iterator.hasNext() ) { // MetadataRecord next = iterator.next(); // if ( next.getProperty().getId().equals( property ) ) { // result.add( next ); // iterator.remove(); // } // } // // return result; // } // // }
import com.petpet.c3po.api.adaptor.PostProcessingRule; import com.petpet.c3po.api.model.Element;
/******************************************************************************* * Copyright 2013 Petar Petrov <me@petarpetrov.org> * * 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 com.petpet.c3po.adaptor.rules; /** * This {@link PostProcessingRule} applies the given collection to every * {@link Element} that is processed. * * Note that this rule is always turned on. * * @author Petar Petrov <me@petarpetrov.org> * */ public class AssignCollectionToElementRule implements PostProcessingRule { /** * The collection to apply. */ private String collectionName; /** * Creates the rule. * * @param name * the name of the collection. */ public AssignCollectionToElementRule(String name) { this.collectionName = name; } /** * Has a very high priority. */ @Override public int getPriority() { return 990; } /** * Sets the collection of the given element to the colleciton name and returns * it. */ @Override
// Path: c3po-api/src/main/java/com/petpet/c3po/api/adaptor/PostProcessingRule.java // public interface PostProcessingRule extends ProcessingRule { // // /** // * This method does some processing over the passed element and returns it. It // * can do any kind of post processing to the element. // * // * @param e // * the element to process. // * @return the processed element. // */ // Element process( Element e ); // // } // // Path: c3po-api/src/main/java/com/petpet/c3po/api/model/Element.java // public class Element implements Model { // // /** // * A back-end related identifier of this object. // */ // private String id; // // /** // * The collection to which the current element belongs. // */ // private String collection; // // /** // * Some non-unique name of this element. // */ // private String name; // // /** // * Some unique identifier of this element that references the original file // * back in the source. // */ // private String uid; // // /** // * A list of {@link MetadataRecord} info. // */ // private List<MetadataRecord> metadata; // // /** // * Creates an element with the given uid and name. // * // * @param uid // * the unique identifier of this element. // * @param name // * the name of this element. // */ // public Element(String uid, String name) { // this.uid = uid; // this.name = name; // this.metadata = new ArrayList<MetadataRecord>(); // } // // /** // * Creates an element with the given uid, name and collection. // * // * @param collection // * @param uid // * @param name // */ // public Element(String collection, String uid, String name) { // this( uid, name ); // this.collection = collection; // } // // public String getCollection() { // return collection; // } // // public void setCollection( String collection ) { // this.collection = collection; // } // // public String getName() { // return name; // } // // public void setName( String name ) { // this.name = name; // } // // public String getUid() { // return uid; // } // // public void setUid( String uid ) { // this.uid = uid; // } // // public List<MetadataRecord> getMetadata() { // return metadata; // } // // public void setMetadata( List<MetadataRecord> metadata ) { // this.metadata = metadata; // } // // public String getId() { // return id; // } // // public void setId( String id ) { // this.id = id; // } // // /** // * Removes all records for the given property id and returns a list of all // * removed meta data records. // * // * @param property // * the id of the property // * @return returns the records of the element matching this property that were // * deleted. // */ // public List<MetadataRecord> removeMetadata( String property ) { // List<MetadataRecord> result = new ArrayList<MetadataRecord>(); // // Iterator<MetadataRecord> iterator = this.metadata.iterator(); // while ( iterator.hasNext() ) { // MetadataRecord next = iterator.next(); // if ( next.getProperty().getId().equals( property ) ) { // result.add( next ); // iterator.remove(); // } // } // // return result; // } // // } // Path: c3po-core/src/main/java/com/petpet/c3po/adaptor/rules/AssignCollectionToElementRule.java import com.petpet.c3po.api.adaptor.PostProcessingRule; import com.petpet.c3po.api.model.Element; /******************************************************************************* * Copyright 2013 Petar Petrov <me@petarpetrov.org> * * 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 com.petpet.c3po.adaptor.rules; /** * This {@link PostProcessingRule} applies the given collection to every * {@link Element} that is processed. * * Note that this rule is always turned on. * * @author Petar Petrov <me@petarpetrov.org> * */ public class AssignCollectionToElementRule implements PostProcessingRule { /** * The collection to apply. */ private String collectionName; /** * Creates the rule. * * @param name * the name of the collection. */ public AssignCollectionToElementRule(String name) { this.collectionName = name; } /** * Has a very high priority. */ @Override public int getPriority() { return 990; } /** * Sets the collection of the given element to the colleciton name and returns * it. */ @Override
public Element process( Element e ) {
peshkira/c3po
c3po-api/src/main/java/com/petpet/c3po/api/model/Property.java
// Path: c3po-api/src/main/java/com/petpet/c3po/api/model/helper/PropertyType.java // public enum PropertyType { // STRING, BOOL, INTEGER, FLOAT, DATE, ARRAY // }
import com.petpet.c3po.api.model.helper.PropertyType;
/******************************************************************************* * Copyright 2013 Petar Petrov <me@petarpetrov.org> * * 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 com.petpet.c3po.api.model; /** * A domain object encapsulating a property document. * * @author Petar Petrov <me@petarpetrov.org> * */ public class Property implements Model { /** * The id of the proeprty. */ private String id; /** * The key of the property. */ private String key; /** * The type of the property. */ private String type; /** * A default constructor. */ public Property() { } /** * Creates a property with the given key as key and id and sets the type to a * string. * * @param key * the key of the property. */ public Property(String key) { this.id = key; this.key = key;
// Path: c3po-api/src/main/java/com/petpet/c3po/api/model/helper/PropertyType.java // public enum PropertyType { // STRING, BOOL, INTEGER, FLOAT, DATE, ARRAY // } // Path: c3po-api/src/main/java/com/petpet/c3po/api/model/Property.java import com.petpet.c3po.api.model.helper.PropertyType; /******************************************************************************* * Copyright 2013 Petar Petrov <me@petarpetrov.org> * * 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 com.petpet.c3po.api.model; /** * A domain object encapsulating a property document. * * @author Petar Petrov <me@petarpetrov.org> * */ public class Property implements Model { /** * The id of the proeprty. */ private String id; /** * The key of the property. */ private String key; /** * The type of the property. */ private String type; /** * A default constructor. */ public Property() { } /** * Creates a property with the given key as key and id and sets the type to a * string. * * @param key * the key of the property. */ public Property(String key) { this.id = key; this.key = key;
this.type = PropertyType.STRING.name();
peshkira/c3po
c3po-core/src/test/java/com/petpet/c3po/adaptor/rules/HtmlInfoProcessingRuleTest.java
// Path: c3po-api/src/main/java/com/petpet/c3po/api/model/Property.java // public class Property implements Model { // // /** // * The id of the proeprty. // */ // private String id; // // /** // * The key of the property. // */ // private String key; // // /** // * The type of the property. // */ // private String type; // // /** // * A default constructor. // */ // public Property() { // // } // // /** // * Creates a property with the given key as key and id and sets the type to a // * string. // * // * @param key // * the key of the property. // */ // public Property(String key) { // this.id = key; // this.key = key; // this.type = PropertyType.STRING.name(); // } // // /** // * Creates a property with the given key as key and id and sets the type to // * the given type. // * // * @param key // * @param type // */ // public Property(String key, PropertyType type) { // this( key ); // this.type = type.name(); // } // // public void setId( String id ) { // this.id = id; // } // // public String getId() { // return this.id; // } // // public String getKey() { // return key; // } // // public void setKey( String key ) { // this.key = key; // } // // public String getType() { // return type; // } // // public void setType( String type ) { // this.type = type; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + ((id == null) ? 0 : id.hashCode()); // result = prime * result + ((key == null) ? 0 : key.hashCode()); // result = prime * result + ((type == null) ? 0 : type.hashCode()); // return result; // } // // @Override // public boolean equals( Object obj ) { // if ( this == obj ) // return true; // if ( obj == null ) // return false; // if ( getClass() != obj.getClass() ) // return false; // Property other = (Property) obj; // if ( id == null ) { // if ( other.id != null ) // return false; // } else if ( !id.equals( other.id ) ) // return false; // if ( key == null ) { // if ( other.key != null ) // return false; // } else if ( !key.equals( other.key ) ) // return false; // if ( type == null ) { // if ( other.type != null ) // return false; // } else if ( !type.equals( other.type ) ) // return false; // return true; // } // // }
import junit.framework.Assert; import org.junit.Test; import org.mockito.Mockito; import com.petpet.c3po.api.model.Property;
/******************************************************************************* * Copyright 2013 Petar Petrov <me@petarpetrov.org> * * 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 com.petpet.c3po.adaptor.rules; public class HtmlInfoProcessingRuleTest { @Test public void shouldTestFaultyTagOccurrences() throws Exception {
// Path: c3po-api/src/main/java/com/petpet/c3po/api/model/Property.java // public class Property implements Model { // // /** // * The id of the proeprty. // */ // private String id; // // /** // * The key of the property. // */ // private String key; // // /** // * The type of the property. // */ // private String type; // // /** // * A default constructor. // */ // public Property() { // // } // // /** // * Creates a property with the given key as key and id and sets the type to a // * string. // * // * @param key // * the key of the property. // */ // public Property(String key) { // this.id = key; // this.key = key; // this.type = PropertyType.STRING.name(); // } // // /** // * Creates a property with the given key as key and id and sets the type to // * the given type. // * // * @param key // * @param type // */ // public Property(String key, PropertyType type) { // this( key ); // this.type = type.name(); // } // // public void setId( String id ) { // this.id = id; // } // // public String getId() { // return this.id; // } // // public String getKey() { // return key; // } // // public void setKey( String key ) { // this.key = key; // } // // public String getType() { // return type; // } // // public void setType( String type ) { // this.type = type; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + ((id == null) ? 0 : id.hashCode()); // result = prime * result + ((key == null) ? 0 : key.hashCode()); // result = prime * result + ((type == null) ? 0 : type.hashCode()); // return result; // } // // @Override // public boolean equals( Object obj ) { // if ( this == obj ) // return true; // if ( obj == null ) // return false; // if ( getClass() != obj.getClass() ) // return false; // Property other = (Property) obj; // if ( id == null ) { // if ( other.id != null ) // return false; // } else if ( !id.equals( other.id ) ) // return false; // if ( key == null ) { // if ( other.key != null ) // return false; // } else if ( !key.equals( other.key ) ) // return false; // if ( type == null ) { // if ( other.type != null ) // return false; // } else if ( !type.equals( other.type ) ) // return false; // return true; // } // // } // Path: c3po-core/src/test/java/com/petpet/c3po/adaptor/rules/HtmlInfoProcessingRuleTest.java import junit.framework.Assert; import org.junit.Test; import org.mockito.Mockito; import com.petpet.c3po.api.model.Property; /******************************************************************************* * Copyright 2013 Petar Petrov <me@petarpetrov.org> * * 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 com.petpet.c3po.adaptor.rules; public class HtmlInfoProcessingRuleTest { @Test public void shouldTestFaultyTagOccurrences() throws Exception {
Property p1 = Mockito.mock(Property.class);
anjlab/sat3
3-sat-core/src/test/java/com/anjlab/sat3/TestHelper.java
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _010_instance = new _010(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _011_instance = new _011(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _100_instance = new _100(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _101_instance = new _101(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _110_instance = new _110(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _111_instance = new _111();
import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._010_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._011_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._100_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._110_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._111_instance; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.io.File; import java.io.IOException; import java.util.Properties; import java.util.Random; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import cern.colt.list.ObjectArrayList; import cern.colt.map.OpenIntObjectHashMap;
-2, 5, -1, // 1 0 1 -5, 1, 6, // 0 1 0 -5, 1, -6, // 1 0 0 5, -1, 6, // 1 0 1 -5, -1, -6, // 1 1 1 1, 6, -3, // 0 0 1 1, -6, -3, // 0 1 1 -1, 6, 3, // 1 0 0 -1, -6, -3, // 1 1 1 6, -3, -4, // 0 0 1 6, 3, -4, // 0 1 1 -6, -3, 4, // 1 1 0 -6, -3, -4 // 1 1 1 }); // VarCount: 8; ClausesCount: 21; TiersCount: 6 assertEquals(21, s2.getClausesCount()); Helper.prettyPrint(s2); // List of ITabularFormula ObjectArrayList cts = new ObjectArrayList(new ITabularFormula[] {s1, s2}); Helper.unify(cts); assertEquals(13, s1.getClausesCount()); assertEquals(15, s2.getClausesCount()); Helper.prettyPrint(s1); Helper.prettyPrint(s2);
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _010_instance = new _010(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _011_instance = new _011(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _100_instance = new _100(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _101_instance = new _101(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _110_instance = new _110(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _111_instance = new _111(); // Path: 3-sat-core/src/test/java/com/anjlab/sat3/TestHelper.java import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._010_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._011_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._100_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._110_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._111_instance; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.io.File; import java.io.IOException; import java.util.Properties; import java.util.Random; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import cern.colt.list.ObjectArrayList; import cern.colt.map.OpenIntObjectHashMap; -2, 5, -1, // 1 0 1 -5, 1, 6, // 0 1 0 -5, 1, -6, // 1 0 0 5, -1, 6, // 1 0 1 -5, -1, -6, // 1 1 1 1, 6, -3, // 0 0 1 1, -6, -3, // 0 1 1 -1, 6, 3, // 1 0 0 -1, -6, -3, // 1 1 1 6, -3, -4, // 0 0 1 6, 3, -4, // 0 1 1 -6, -3, 4, // 1 1 0 -6, -3, -4 // 1 1 1 }); // VarCount: 8; ClausesCount: 21; TiersCount: 6 assertEquals(21, s2.getClausesCount()); Helper.prettyPrint(s2); // List of ITabularFormula ObjectArrayList cts = new ObjectArrayList(new ITabularFormula[] {s1, s2}); Helper.unify(cts); assertEquals(13, s1.getClausesCount()); assertEquals(15, s2.getClausesCount()); Helper.prettyPrint(s1); Helper.prettyPrint(s2);
assertTrue(s1.getTier(0).contains(_001_instance));
anjlab/sat3
3-sat-core/src/test/java/com/anjlab/sat3/TestHelper.java
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _010_instance = new _010(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _011_instance = new _011(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _100_instance = new _100(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _101_instance = new _101(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _110_instance = new _110(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _111_instance = new _111();
import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._010_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._011_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._100_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._110_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._111_instance; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.io.File; import java.io.IOException; import java.util.Properties; import java.util.Random; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import cern.colt.list.ObjectArrayList; import cern.colt.map.OpenIntObjectHashMap;
-5, 1, 6, // 0 1 0 -5, 1, -6, // 1 0 0 5, -1, 6, // 1 0 1 -5, -1, -6, // 1 1 1 1, 6, -3, // 0 0 1 1, -6, -3, // 0 1 1 -1, 6, 3, // 1 0 0 -1, -6, -3, // 1 1 1 6, -3, -4, // 0 0 1 6, 3, -4, // 0 1 1 -6, -3, 4, // 1 1 0 -6, -3, -4 // 1 1 1 }); // VarCount: 8; ClausesCount: 21; TiersCount: 6 assertEquals(21, s2.getClausesCount()); Helper.prettyPrint(s2); // List of ITabularFormula ObjectArrayList cts = new ObjectArrayList(new ITabularFormula[] {s1, s2}); Helper.unify(cts); assertEquals(13, s1.getClausesCount()); assertEquals(15, s2.getClausesCount()); Helper.prettyPrint(s1); Helper.prettyPrint(s2); assertTrue(s1.getTier(0).contains(_001_instance));
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _010_instance = new _010(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _011_instance = new _011(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _100_instance = new _100(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _101_instance = new _101(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _110_instance = new _110(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _111_instance = new _111(); // Path: 3-sat-core/src/test/java/com/anjlab/sat3/TestHelper.java import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._010_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._011_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._100_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._110_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._111_instance; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.io.File; import java.io.IOException; import java.util.Properties; import java.util.Random; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import cern.colt.list.ObjectArrayList; import cern.colt.map.OpenIntObjectHashMap; -5, 1, 6, // 0 1 0 -5, 1, -6, // 1 0 0 5, -1, 6, // 1 0 1 -5, -1, -6, // 1 1 1 1, 6, -3, // 0 0 1 1, -6, -3, // 0 1 1 -1, 6, 3, // 1 0 0 -1, -6, -3, // 1 1 1 6, -3, -4, // 0 0 1 6, 3, -4, // 0 1 1 -6, -3, 4, // 1 1 0 -6, -3, -4 // 1 1 1 }); // VarCount: 8; ClausesCount: 21; TiersCount: 6 assertEquals(21, s2.getClausesCount()); Helper.prettyPrint(s2); // List of ITabularFormula ObjectArrayList cts = new ObjectArrayList(new ITabularFormula[] {s1, s2}); Helper.unify(cts); assertEquals(13, s1.getClausesCount()); assertEquals(15, s2.getClausesCount()); Helper.prettyPrint(s1); Helper.prettyPrint(s2); assertTrue(s1.getTier(0).contains(_001_instance));
assertTrue(s1.getTier(0).contains(_101_instance));
anjlab/sat3
3-sat-core/src/test/java/com/anjlab/sat3/TestHelper.java
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _010_instance = new _010(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _011_instance = new _011(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _100_instance = new _100(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _101_instance = new _101(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _110_instance = new _110(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _111_instance = new _111();
import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._010_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._011_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._100_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._110_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._111_instance; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.io.File; import java.io.IOException; import java.util.Properties; import java.util.Random; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import cern.colt.list.ObjectArrayList; import cern.colt.map.OpenIntObjectHashMap;
-5, 1, -6, // 1 0 0 5, -1, 6, // 1 0 1 -5, -1, -6, // 1 1 1 1, 6, -3, // 0 0 1 1, -6, -3, // 0 1 1 -1, 6, 3, // 1 0 0 -1, -6, -3, // 1 1 1 6, -3, -4, // 0 0 1 6, 3, -4, // 0 1 1 -6, -3, 4, // 1 1 0 -6, -3, -4 // 1 1 1 }); // VarCount: 8; ClausesCount: 21; TiersCount: 6 assertEquals(21, s2.getClausesCount()); Helper.prettyPrint(s2); // List of ITabularFormula ObjectArrayList cts = new ObjectArrayList(new ITabularFormula[] {s1, s2}); Helper.unify(cts); assertEquals(13, s1.getClausesCount()); assertEquals(15, s2.getClausesCount()); Helper.prettyPrint(s1); Helper.prettyPrint(s2); assertTrue(s1.getTier(0).contains(_001_instance)); assertTrue(s1.getTier(0).contains(_101_instance));
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _010_instance = new _010(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _011_instance = new _011(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _100_instance = new _100(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _101_instance = new _101(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _110_instance = new _110(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _111_instance = new _111(); // Path: 3-sat-core/src/test/java/com/anjlab/sat3/TestHelper.java import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._010_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._011_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._100_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._110_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._111_instance; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.io.File; import java.io.IOException; import java.util.Properties; import java.util.Random; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import cern.colt.list.ObjectArrayList; import cern.colt.map.OpenIntObjectHashMap; -5, 1, -6, // 1 0 0 5, -1, 6, // 1 0 1 -5, -1, -6, // 1 1 1 1, 6, -3, // 0 0 1 1, -6, -3, // 0 1 1 -1, 6, 3, // 1 0 0 -1, -6, -3, // 1 1 1 6, -3, -4, // 0 0 1 6, 3, -4, // 0 1 1 -6, -3, 4, // 1 1 0 -6, -3, -4 // 1 1 1 }); // VarCount: 8; ClausesCount: 21; TiersCount: 6 assertEquals(21, s2.getClausesCount()); Helper.prettyPrint(s2); // List of ITabularFormula ObjectArrayList cts = new ObjectArrayList(new ITabularFormula[] {s1, s2}); Helper.unify(cts); assertEquals(13, s1.getClausesCount()); assertEquals(15, s2.getClausesCount()); Helper.prettyPrint(s1); Helper.prettyPrint(s2); assertTrue(s1.getTier(0).contains(_001_instance)); assertTrue(s1.getTier(0).contains(_101_instance));
assertTrue(s1.getTier(1).contains(_010_instance));
anjlab/sat3
3-sat-core/src/test/java/com/anjlab/sat3/TestHelper.java
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _010_instance = new _010(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _011_instance = new _011(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _100_instance = new _100(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _101_instance = new _101(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _110_instance = new _110(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _111_instance = new _111();
import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._010_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._011_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._100_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._110_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._111_instance; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.io.File; import java.io.IOException; import java.util.Properties; import java.util.Random; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import cern.colt.list.ObjectArrayList; import cern.colt.map.OpenIntObjectHashMap;
5, -1, 6, // 1 0 1 -5, -1, -6, // 1 1 1 1, 6, -3, // 0 0 1 1, -6, -3, // 0 1 1 -1, 6, 3, // 1 0 0 -1, -6, -3, // 1 1 1 6, -3, -4, // 0 0 1 6, 3, -4, // 0 1 1 -6, -3, 4, // 1 1 0 -6, -3, -4 // 1 1 1 }); // VarCount: 8; ClausesCount: 21; TiersCount: 6 assertEquals(21, s2.getClausesCount()); Helper.prettyPrint(s2); // List of ITabularFormula ObjectArrayList cts = new ObjectArrayList(new ITabularFormula[] {s1, s2}); Helper.unify(cts); assertEquals(13, s1.getClausesCount()); assertEquals(15, s2.getClausesCount()); Helper.prettyPrint(s1); Helper.prettyPrint(s2); assertTrue(s1.getTier(0).contains(_001_instance)); assertTrue(s1.getTier(0).contains(_101_instance)); assertTrue(s1.getTier(1).contains(_010_instance));
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _010_instance = new _010(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _011_instance = new _011(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _100_instance = new _100(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _101_instance = new _101(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _110_instance = new _110(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _111_instance = new _111(); // Path: 3-sat-core/src/test/java/com/anjlab/sat3/TestHelper.java import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._010_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._011_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._100_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._110_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._111_instance; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.io.File; import java.io.IOException; import java.util.Properties; import java.util.Random; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import cern.colt.list.ObjectArrayList; import cern.colt.map.OpenIntObjectHashMap; 5, -1, 6, // 1 0 1 -5, -1, -6, // 1 1 1 1, 6, -3, // 0 0 1 1, -6, -3, // 0 1 1 -1, 6, 3, // 1 0 0 -1, -6, -3, // 1 1 1 6, -3, -4, // 0 0 1 6, 3, -4, // 0 1 1 -6, -3, 4, // 1 1 0 -6, -3, -4 // 1 1 1 }); // VarCount: 8; ClausesCount: 21; TiersCount: 6 assertEquals(21, s2.getClausesCount()); Helper.prettyPrint(s2); // List of ITabularFormula ObjectArrayList cts = new ObjectArrayList(new ITabularFormula[] {s1, s2}); Helper.unify(cts); assertEquals(13, s1.getClausesCount()); assertEquals(15, s2.getClausesCount()); Helper.prettyPrint(s1); Helper.prettyPrint(s2); assertTrue(s1.getTier(0).contains(_001_instance)); assertTrue(s1.getTier(0).contains(_101_instance)); assertTrue(s1.getTier(1).contains(_010_instance));
assertTrue(s1.getTier(1).contains(_011_instance));
anjlab/sat3
3-sat-core/src/test/java/com/anjlab/sat3/TestHelper.java
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _010_instance = new _010(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _011_instance = new _011(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _100_instance = new _100(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _101_instance = new _101(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _110_instance = new _110(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _111_instance = new _111();
import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._010_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._011_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._100_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._110_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._111_instance; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.io.File; import java.io.IOException; import java.util.Properties; import java.util.Random; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import cern.colt.list.ObjectArrayList; import cern.colt.map.OpenIntObjectHashMap;
1, 6, -3, // 0 0 1 1, -6, -3, // 0 1 1 -1, 6, 3, // 1 0 0 -1, -6, -3, // 1 1 1 6, -3, -4, // 0 0 1 6, 3, -4, // 0 1 1 -6, -3, 4, // 1 1 0 -6, -3, -4 // 1 1 1 }); // VarCount: 8; ClausesCount: 21; TiersCount: 6 assertEquals(21, s2.getClausesCount()); Helper.prettyPrint(s2); // List of ITabularFormula ObjectArrayList cts = new ObjectArrayList(new ITabularFormula[] {s1, s2}); Helper.unify(cts); assertEquals(13, s1.getClausesCount()); assertEquals(15, s2.getClausesCount()); Helper.prettyPrint(s1); Helper.prettyPrint(s2); assertTrue(s1.getTier(0).contains(_001_instance)); assertTrue(s1.getTier(0).contains(_101_instance)); assertTrue(s1.getTier(1).contains(_010_instance)); assertTrue(s1.getTier(1).contains(_011_instance)); assertTrue(s1.getTier(2).contains(_101_instance));
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _010_instance = new _010(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _011_instance = new _011(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _100_instance = new _100(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _101_instance = new _101(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _110_instance = new _110(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _111_instance = new _111(); // Path: 3-sat-core/src/test/java/com/anjlab/sat3/TestHelper.java import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._010_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._011_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._100_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._110_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._111_instance; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.io.File; import java.io.IOException; import java.util.Properties; import java.util.Random; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import cern.colt.list.ObjectArrayList; import cern.colt.map.OpenIntObjectHashMap; 1, 6, -3, // 0 0 1 1, -6, -3, // 0 1 1 -1, 6, 3, // 1 0 0 -1, -6, -3, // 1 1 1 6, -3, -4, // 0 0 1 6, 3, -4, // 0 1 1 -6, -3, 4, // 1 1 0 -6, -3, -4 // 1 1 1 }); // VarCount: 8; ClausesCount: 21; TiersCount: 6 assertEquals(21, s2.getClausesCount()); Helper.prettyPrint(s2); // List of ITabularFormula ObjectArrayList cts = new ObjectArrayList(new ITabularFormula[] {s1, s2}); Helper.unify(cts); assertEquals(13, s1.getClausesCount()); assertEquals(15, s2.getClausesCount()); Helper.prettyPrint(s1); Helper.prettyPrint(s2); assertTrue(s1.getTier(0).contains(_001_instance)); assertTrue(s1.getTier(0).contains(_101_instance)); assertTrue(s1.getTier(1).contains(_010_instance)); assertTrue(s1.getTier(1).contains(_011_instance)); assertTrue(s1.getTier(2).contains(_101_instance));
assertTrue(s1.getTier(2).contains(_111_instance));
anjlab/sat3
3-sat-core/src/test/java/com/anjlab/sat3/TestHelper.java
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _010_instance = new _010(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _011_instance = new _011(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _100_instance = new _100(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _101_instance = new _101(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _110_instance = new _110(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _111_instance = new _111();
import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._010_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._011_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._100_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._110_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._111_instance; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.io.File; import java.io.IOException; import java.util.Properties; import java.util.Random; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import cern.colt.list.ObjectArrayList; import cern.colt.map.OpenIntObjectHashMap;
-1, 6, 3, // 1 0 0 -1, -6, -3, // 1 1 1 6, -3, -4, // 0 0 1 6, 3, -4, // 0 1 1 -6, -3, 4, // 1 1 0 -6, -3, -4 // 1 1 1 }); // VarCount: 8; ClausesCount: 21; TiersCount: 6 assertEquals(21, s2.getClausesCount()); Helper.prettyPrint(s2); // List of ITabularFormula ObjectArrayList cts = new ObjectArrayList(new ITabularFormula[] {s1, s2}); Helper.unify(cts); assertEquals(13, s1.getClausesCount()); assertEquals(15, s2.getClausesCount()); Helper.prettyPrint(s1); Helper.prettyPrint(s2); assertTrue(s1.getTier(0).contains(_001_instance)); assertTrue(s1.getTier(0).contains(_101_instance)); assertTrue(s1.getTier(1).contains(_010_instance)); assertTrue(s1.getTier(1).contains(_011_instance)); assertTrue(s1.getTier(2).contains(_101_instance)); assertTrue(s1.getTier(2).contains(_111_instance)); assertTrue(s1.getTier(3).contains(_011_instance));
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _010_instance = new _010(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _011_instance = new _011(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _100_instance = new _100(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _101_instance = new _101(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _110_instance = new _110(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _111_instance = new _111(); // Path: 3-sat-core/src/test/java/com/anjlab/sat3/TestHelper.java import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._010_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._011_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._100_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._110_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._111_instance; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.io.File; import java.io.IOException; import java.util.Properties; import java.util.Random; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import cern.colt.list.ObjectArrayList; import cern.colt.map.OpenIntObjectHashMap; -1, 6, 3, // 1 0 0 -1, -6, -3, // 1 1 1 6, -3, -4, // 0 0 1 6, 3, -4, // 0 1 1 -6, -3, 4, // 1 1 0 -6, -3, -4 // 1 1 1 }); // VarCount: 8; ClausesCount: 21; TiersCount: 6 assertEquals(21, s2.getClausesCount()); Helper.prettyPrint(s2); // List of ITabularFormula ObjectArrayList cts = new ObjectArrayList(new ITabularFormula[] {s1, s2}); Helper.unify(cts); assertEquals(13, s1.getClausesCount()); assertEquals(15, s2.getClausesCount()); Helper.prettyPrint(s1); Helper.prettyPrint(s2); assertTrue(s1.getTier(0).contains(_001_instance)); assertTrue(s1.getTier(0).contains(_101_instance)); assertTrue(s1.getTier(1).contains(_010_instance)); assertTrue(s1.getTier(1).contains(_011_instance)); assertTrue(s1.getTier(2).contains(_101_instance)); assertTrue(s1.getTier(2).contains(_111_instance)); assertTrue(s1.getTier(3).contains(_011_instance));
assertTrue(s1.getTier(3).contains(_110_instance));
anjlab/sat3
3-sat-core/src/test/java/com/anjlab/sat3/TestHelper.java
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _010_instance = new _010(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _011_instance = new _011(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _100_instance = new _100(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _101_instance = new _101(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _110_instance = new _110(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _111_instance = new _111();
import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._010_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._011_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._100_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._110_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._111_instance; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.io.File; import java.io.IOException; import java.util.Properties; import java.util.Random; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import cern.colt.list.ObjectArrayList; import cern.colt.map.OpenIntObjectHashMap;
-6, -3, -4 // 1 1 1 }); // VarCount: 8; ClausesCount: 21; TiersCount: 6 assertEquals(21, s2.getClausesCount()); Helper.prettyPrint(s2); // List of ITabularFormula ObjectArrayList cts = new ObjectArrayList(new ITabularFormula[] {s1, s2}); Helper.unify(cts); assertEquals(13, s1.getClausesCount()); assertEquals(15, s2.getClausesCount()); Helper.prettyPrint(s1); Helper.prettyPrint(s2); assertTrue(s1.getTier(0).contains(_001_instance)); assertTrue(s1.getTier(0).contains(_101_instance)); assertTrue(s1.getTier(1).contains(_010_instance)); assertTrue(s1.getTier(1).contains(_011_instance)); assertTrue(s1.getTier(2).contains(_101_instance)); assertTrue(s1.getTier(2).contains(_111_instance)); assertTrue(s1.getTier(3).contains(_011_instance)); assertTrue(s1.getTier(3).contains(_110_instance)); assertTrue(s1.getTier(3).contains(_111_instance)); assertTrue(s1.getTier(4).contains(_101_instance)); assertTrue(s1.getTier(4).contains(_110_instance)); assertTrue(s1.getTier(5).contains(_011_instance));
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _010_instance = new _010(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _011_instance = new _011(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _100_instance = new _100(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _101_instance = new _101(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _110_instance = new _110(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _111_instance = new _111(); // Path: 3-sat-core/src/test/java/com/anjlab/sat3/TestHelper.java import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._010_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._011_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._100_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._110_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._111_instance; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.io.File; import java.io.IOException; import java.util.Properties; import java.util.Random; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import cern.colt.list.ObjectArrayList; import cern.colt.map.OpenIntObjectHashMap; -6, -3, -4 // 1 1 1 }); // VarCount: 8; ClausesCount: 21; TiersCount: 6 assertEquals(21, s2.getClausesCount()); Helper.prettyPrint(s2); // List of ITabularFormula ObjectArrayList cts = new ObjectArrayList(new ITabularFormula[] {s1, s2}); Helper.unify(cts); assertEquals(13, s1.getClausesCount()); assertEquals(15, s2.getClausesCount()); Helper.prettyPrint(s1); Helper.prettyPrint(s2); assertTrue(s1.getTier(0).contains(_001_instance)); assertTrue(s1.getTier(0).contains(_101_instance)); assertTrue(s1.getTier(1).contains(_010_instance)); assertTrue(s1.getTier(1).contains(_011_instance)); assertTrue(s1.getTier(2).contains(_101_instance)); assertTrue(s1.getTier(2).contains(_111_instance)); assertTrue(s1.getTier(3).contains(_011_instance)); assertTrue(s1.getTier(3).contains(_110_instance)); assertTrue(s1.getTier(3).contains(_111_instance)); assertTrue(s1.getTier(4).contains(_101_instance)); assertTrue(s1.getTier(4).contains(_110_instance)); assertTrue(s1.getTier(5).contains(_011_instance));
assertTrue(s1.getTier(5).contains(_100_instance));
anjlab/sat3
3-sat-core/src/test/java/com/anjlab/sat3/TestHelper.java
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _010_instance = new _010(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _011_instance = new _011(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _100_instance = new _100(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _101_instance = new _101(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _110_instance = new _110(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _111_instance = new _111();
import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._010_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._011_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._100_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._110_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._111_instance; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.io.File; import java.io.IOException; import java.util.Properties; import java.util.Random; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import cern.colt.list.ObjectArrayList; import cern.colt.map.OpenIntObjectHashMap;
assertEquals(21, s2.getClausesCount()); Helper.prettyPrint(s2); // List of ITabularFormula ObjectArrayList cts = new ObjectArrayList(new ITabularFormula[] {s1, s2}); Helper.unify(cts); assertEquals(13, s1.getClausesCount()); assertEquals(15, s2.getClausesCount()); Helper.prettyPrint(s1); Helper.prettyPrint(s2); assertTrue(s1.getTier(0).contains(_001_instance)); assertTrue(s1.getTier(0).contains(_101_instance)); assertTrue(s1.getTier(1).contains(_010_instance)); assertTrue(s1.getTier(1).contains(_011_instance)); assertTrue(s1.getTier(2).contains(_101_instance)); assertTrue(s1.getTier(2).contains(_111_instance)); assertTrue(s1.getTier(3).contains(_011_instance)); assertTrue(s1.getTier(3).contains(_110_instance)); assertTrue(s1.getTier(3).contains(_111_instance)); assertTrue(s1.getTier(4).contains(_101_instance)); assertTrue(s1.getTier(4).contains(_110_instance)); assertTrue(s1.getTier(5).contains(_011_instance)); assertTrue(s1.getTier(5).contains(_100_instance));
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _010_instance = new _010(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _011_instance = new _011(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _100_instance = new _100(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _101_instance = new _101(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _110_instance = new _110(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _111_instance = new _111(); // Path: 3-sat-core/src/test/java/com/anjlab/sat3/TestHelper.java import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._010_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._011_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._100_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._110_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._111_instance; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.io.File; import java.io.IOException; import java.util.Properties; import java.util.Random; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import cern.colt.list.ObjectArrayList; import cern.colt.map.OpenIntObjectHashMap; assertEquals(21, s2.getClausesCount()); Helper.prettyPrint(s2); // List of ITabularFormula ObjectArrayList cts = new ObjectArrayList(new ITabularFormula[] {s1, s2}); Helper.unify(cts); assertEquals(13, s1.getClausesCount()); assertEquals(15, s2.getClausesCount()); Helper.prettyPrint(s1); Helper.prettyPrint(s2); assertTrue(s1.getTier(0).contains(_001_instance)); assertTrue(s1.getTier(0).contains(_101_instance)); assertTrue(s1.getTier(1).contains(_010_instance)); assertTrue(s1.getTier(1).contains(_011_instance)); assertTrue(s1.getTier(2).contains(_101_instance)); assertTrue(s1.getTier(2).contains(_111_instance)); assertTrue(s1.getTier(3).contains(_011_instance)); assertTrue(s1.getTier(3).contains(_110_instance)); assertTrue(s1.getTier(3).contains(_111_instance)); assertTrue(s1.getTier(4).contains(_101_instance)); assertTrue(s1.getTier(4).contains(_110_instance)); assertTrue(s1.getTier(5).contains(_011_instance)); assertTrue(s1.getTier(5).contains(_100_instance));
assertTrue(s2.getTier(0).contains(_000_instance));
anjlab/sat3
3-sat-core/src/test/java/com/anjlab/sat3/TestJoinMethods.java
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/Helper.java // public static ITabularFormula createFormula(int... values) // { // if (values.length%3 != 0) // { // throw new IllegalArgumentException("Number of values must be a multiple of 3"); // } // ITabularFormula formula = new SimpleFormula(); // for (int i = 0; i < values.length; i +=3) // { // SimpleTriplet triplet = new SimpleTriplet(values[i], values[i + 1], values[i + 2]); // formula.unionOrAdd(triplet); // } // return formula; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimplePermutation.java // public static IPermutation createPermutation(int... variables) // { // IPermutation permutation = new SimplePermutation(); // // for (int varName : variables) // { // permutation.add(varName); // } // // return permutation; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _101_instance = new _101(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000();
import org.junit.BeforeClass; import org.junit.Test; import static com.anjlab.sat3.Helper.createFormula; import static com.anjlab.sat3.SimplePermutation.createPermutation; import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue;
/* * Copyright (c) 2010 AnjLab * * This file is part of * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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 * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * If not, see <http://www.gnu.org/licenses/>. */ package com.anjlab.sat3; public class TestJoinMethods { @BeforeClass public static void setup() { Helper.UsePrettyPrint = true; Helper.EnableAssertions = true; Helper.UseUniversalVarNames = true; System.out.println(TestJoinMethods.class.getName()); } @Test public void testJoin2BetweenTiers() throws Throwable { for (int a1 = 1; a1 <= 3; a1++) for (int b1 = 1; b1 <= 3; b1++) for (int c1 = 1; c1 <= 3; c1++) for (int a2 = 3; a2 <= 5; a2++) for (int b2 = 3; b2 <= 5; b2++) for (int c2 = 3; c2 <= 5; c2++) for (int a3 = 5; a3 <= 7; a3++) for (int b3 = 5; b3 <= 7; b3++) for (int c3 = 5; c3 <= 7; c3++) { if (a1 == b1 || a1 == c1 || b1 == c1) continue; if (a2 == b2 || a2 == c2 || b2 == c2) continue; if (a3 == b3 || a3 == c3 || b3 == c3) continue; Join2BetweenTiers method = new Join2BetweenTiers();
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/Helper.java // public static ITabularFormula createFormula(int... values) // { // if (values.length%3 != 0) // { // throw new IllegalArgumentException("Number of values must be a multiple of 3"); // } // ITabularFormula formula = new SimpleFormula(); // for (int i = 0; i < values.length; i +=3) // { // SimpleTriplet triplet = new SimpleTriplet(values[i], values[i + 1], values[i + 2]); // formula.unionOrAdd(triplet); // } // return formula; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimplePermutation.java // public static IPermutation createPermutation(int... variables) // { // IPermutation permutation = new SimplePermutation(); // // for (int varName : variables) // { // permutation.add(varName); // } // // return permutation; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _101_instance = new _101(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // Path: 3-sat-core/src/test/java/com/anjlab/sat3/TestJoinMethods.java import org.junit.BeforeClass; import org.junit.Test; import static com.anjlab.sat3.Helper.createFormula; import static com.anjlab.sat3.SimplePermutation.createPermutation; import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; /* * Copyright (c) 2010 AnjLab * * This file is part of * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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 * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * If not, see <http://www.gnu.org/licenses/>. */ package com.anjlab.sat3; public class TestJoinMethods { @BeforeClass public static void setup() { Helper.UsePrettyPrint = true; Helper.EnableAssertions = true; Helper.UseUniversalVarNames = true; System.out.println(TestJoinMethods.class.getName()); } @Test public void testJoin2BetweenTiers() throws Throwable { for (int a1 = 1; a1 <= 3; a1++) for (int b1 = 1; b1 <= 3; b1++) for (int c1 = 1; c1 <= 3; c1++) for (int a2 = 3; a2 <= 5; a2++) for (int b2 = 3; b2 <= 5; b2++) for (int c2 = 3; c2 <= 5; c2++) for (int a3 = 5; a3 <= 7; a3++) for (int b3 = 5; b3 <= 7; b3++) for (int c3 = 5; c3 <= 7; c3++) { if (a1 == b1 || a1 == c1 || b1 == c1) continue; if (a2 == b2 || a2 == c2 || b2 == c2) continue; if (a3 == b3 || a3 == c3 || b3 == c3) continue; Join2BetweenTiers method = new Join2BetweenTiers();
ITabularFormula formula = createFormula(a1, b1, c1, a3, b3, c3);
anjlab/sat3
3-sat-core/src/test/java/com/anjlab/sat3/TestJoinMethods.java
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/Helper.java // public static ITabularFormula createFormula(int... values) // { // if (values.length%3 != 0) // { // throw new IllegalArgumentException("Number of values must be a multiple of 3"); // } // ITabularFormula formula = new SimpleFormula(); // for (int i = 0; i < values.length; i +=3) // { // SimpleTriplet triplet = new SimpleTriplet(values[i], values[i + 1], values[i + 2]); // formula.unionOrAdd(triplet); // } // return formula; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimplePermutation.java // public static IPermutation createPermutation(int... variables) // { // IPermutation permutation = new SimplePermutation(); // // for (int varName : variables) // { // permutation.add(varName); // } // // return permutation; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _101_instance = new _101(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000();
import org.junit.BeforeClass; import org.junit.Test; import static com.anjlab.sat3.Helper.createFormula; import static com.anjlab.sat3.SimplePermutation.createPermutation; import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue;
/* * Copyright (c) 2010 AnjLab * * This file is part of * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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 * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * If not, see <http://www.gnu.org/licenses/>. */ package com.anjlab.sat3; public class TestJoinMethods { @BeforeClass public static void setup() { Helper.UsePrettyPrint = true; Helper.EnableAssertions = true; Helper.UseUniversalVarNames = true; System.out.println(TestJoinMethods.class.getName()); } @Test public void testJoin2BetweenTiers() throws Throwable { for (int a1 = 1; a1 <= 3; a1++) for (int b1 = 1; b1 <= 3; b1++) for (int c1 = 1; c1 <= 3; c1++) for (int a2 = 3; a2 <= 5; a2++) for (int b2 = 3; b2 <= 5; b2++) for (int c2 = 3; c2 <= 5; c2++) for (int a3 = 5; a3 <= 7; a3++) for (int b3 = 5; b3 <= 7; b3++) for (int c3 = 5; c3 <= 7; c3++) { if (a1 == b1 || a1 == c1 || b1 == c1) continue; if (a2 == b2 || a2 == c2 || b2 == c2) continue; if (a3 == b3 || a3 == c3 || b3 == c3) continue; Join2BetweenTiers method = new Join2BetweenTiers(); ITabularFormula formula = createFormula(a1, b1, c1, a3, b3, c3); SimpleTier tier = new SimpleTier(a2, b2, c2);
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/Helper.java // public static ITabularFormula createFormula(int... values) // { // if (values.length%3 != 0) // { // throw new IllegalArgumentException("Number of values must be a multiple of 3"); // } // ITabularFormula formula = new SimpleFormula(); // for (int i = 0; i < values.length; i +=3) // { // SimpleTriplet triplet = new SimpleTriplet(values[i], values[i + 1], values[i + 2]); // formula.unionOrAdd(triplet); // } // return formula; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimplePermutation.java // public static IPermutation createPermutation(int... variables) // { // IPermutation permutation = new SimplePermutation(); // // for (int varName : variables) // { // permutation.add(varName); // } // // return permutation; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _101_instance = new _101(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // Path: 3-sat-core/src/test/java/com/anjlab/sat3/TestJoinMethods.java import org.junit.BeforeClass; import org.junit.Test; import static com.anjlab.sat3.Helper.createFormula; import static com.anjlab.sat3.SimplePermutation.createPermutation; import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; /* * Copyright (c) 2010 AnjLab * * This file is part of * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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 * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * If not, see <http://www.gnu.org/licenses/>. */ package com.anjlab.sat3; public class TestJoinMethods { @BeforeClass public static void setup() { Helper.UsePrettyPrint = true; Helper.EnableAssertions = true; Helper.UseUniversalVarNames = true; System.out.println(TestJoinMethods.class.getName()); } @Test public void testJoin2BetweenTiers() throws Throwable { for (int a1 = 1; a1 <= 3; a1++) for (int b1 = 1; b1 <= 3; b1++) for (int c1 = 1; c1 <= 3; c1++) for (int a2 = 3; a2 <= 5; a2++) for (int b2 = 3; b2 <= 5; b2++) for (int c2 = 3; c2 <= 5; c2++) for (int a3 = 5; a3 <= 7; a3++) for (int b3 = 5; b3 <= 7; b3++) for (int c3 = 5; c3 <= 7; c3++) { if (a1 == b1 || a1 == c1 || b1 == c1) continue; if (a2 == b2 || a2 == c2 || b2 == c2) continue; if (a3 == b3 || a3 == c3 || b3 == c3) continue; Join2BetweenTiers method = new Join2BetweenTiers(); ITabularFormula formula = createFormula(a1, b1, c1, a3, b3, c3); SimpleTier tier = new SimpleTier(a2, b2, c2);
tier.add(_101_instance);
anjlab/sat3
3-sat-core/src/test/java/com/anjlab/sat3/TestJoinMethods.java
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/Helper.java // public static ITabularFormula createFormula(int... values) // { // if (values.length%3 != 0) // { // throw new IllegalArgumentException("Number of values must be a multiple of 3"); // } // ITabularFormula formula = new SimpleFormula(); // for (int i = 0; i < values.length; i +=3) // { // SimpleTriplet triplet = new SimpleTriplet(values[i], values[i + 1], values[i + 2]); // formula.unionOrAdd(triplet); // } // return formula; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimplePermutation.java // public static IPermutation createPermutation(int... variables) // { // IPermutation permutation = new SimplePermutation(); // // for (int varName : variables) // { // permutation.add(varName); // } // // return permutation; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _101_instance = new _101(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000();
import org.junit.BeforeClass; import org.junit.Test; import static com.anjlab.sat3.Helper.createFormula; import static com.anjlab.sat3.SimplePermutation.createPermutation; import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue;
} @Test public void testJoin2BetweenTiers() throws Throwable { for (int a1 = 1; a1 <= 3; a1++) for (int b1 = 1; b1 <= 3; b1++) for (int c1 = 1; c1 <= 3; c1++) for (int a2 = 3; a2 <= 5; a2++) for (int b2 = 3; b2 <= 5; b2++) for (int c2 = 3; c2 <= 5; c2++) for (int a3 = 5; a3 <= 7; a3++) for (int b3 = 5; b3 <= 7; b3++) for (int c3 = 5; c3 <= 7; c3++) { if (a1 == b1 || a1 == c1 || b1 == c1) continue; if (a2 == b2 || a2 == c2 || b2 == c2) continue; if (a3 == b3 || a3 == c3 || b3 == c3) continue; Join2BetweenTiers method = new Join2BetweenTiers(); ITabularFormula formula = createFormula(a1, b1, c1, a3, b3, c3); SimpleTier tier = new SimpleTier(a2, b2, c2); tier.add(_101_instance); try { assertTrue("Should join", method.tryJoin(formula, tier)); assertEquals(3, formula.getPermutation().get(2)); assertEquals(4, formula.getPermutation().get(3)); assertEquals(5, formula.getPermutation().get(4));
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/Helper.java // public static ITabularFormula createFormula(int... values) // { // if (values.length%3 != 0) // { // throw new IllegalArgumentException("Number of values must be a multiple of 3"); // } // ITabularFormula formula = new SimpleFormula(); // for (int i = 0; i < values.length; i +=3) // { // SimpleTriplet triplet = new SimpleTriplet(values[i], values[i + 1], values[i + 2]); // formula.unionOrAdd(triplet); // } // return formula; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimplePermutation.java // public static IPermutation createPermutation(int... variables) // { // IPermutation permutation = new SimplePermutation(); // // for (int varName : variables) // { // permutation.add(varName); // } // // return permutation; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _101_instance = new _101(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // Path: 3-sat-core/src/test/java/com/anjlab/sat3/TestJoinMethods.java import org.junit.BeforeClass; import org.junit.Test; import static com.anjlab.sat3.Helper.createFormula; import static com.anjlab.sat3.SimplePermutation.createPermutation; import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; } @Test public void testJoin2BetweenTiers() throws Throwable { for (int a1 = 1; a1 <= 3; a1++) for (int b1 = 1; b1 <= 3; b1++) for (int c1 = 1; c1 <= 3; c1++) for (int a2 = 3; a2 <= 5; a2++) for (int b2 = 3; b2 <= 5; b2++) for (int c2 = 3; c2 <= 5; c2++) for (int a3 = 5; a3 <= 7; a3++) for (int b3 = 5; b3 <= 7; b3++) for (int c3 = 5; c3 <= 7; c3++) { if (a1 == b1 || a1 == c1 || b1 == c1) continue; if (a2 == b2 || a2 == c2 || b2 == c2) continue; if (a3 == b3 || a3 == c3 || b3 == c3) continue; Join2BetweenTiers method = new Join2BetweenTiers(); ITabularFormula formula = createFormula(a1, b1, c1, a3, b3, c3); SimpleTier tier = new SimpleTier(a2, b2, c2); tier.add(_101_instance); try { assertTrue("Should join", method.tryJoin(formula, tier)); assertEquals(3, formula.getPermutation().get(2)); assertEquals(4, formula.getPermutation().get(3)); assertEquals(5, formula.getPermutation().get(4));
formula.complete(createPermutation(1, 2, 3, 4, 5, 6, 7));
anjlab/sat3
3-sat-core/src/test/java/com/anjlab/sat3/TestJoinMethods.java
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/Helper.java // public static ITabularFormula createFormula(int... values) // { // if (values.length%3 != 0) // { // throw new IllegalArgumentException("Number of values must be a multiple of 3"); // } // ITabularFormula formula = new SimpleFormula(); // for (int i = 0; i < values.length; i +=3) // { // SimpleTriplet triplet = new SimpleTriplet(values[i], values[i + 1], values[i + 2]); // formula.unionOrAdd(triplet); // } // return formula; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimplePermutation.java // public static IPermutation createPermutation(int... variables) // { // IPermutation permutation = new SimplePermutation(); // // for (int varName : variables) // { // permutation.add(varName); // } // // return permutation; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _101_instance = new _101(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000();
import org.junit.BeforeClass; import org.junit.Test; import static com.anjlab.sat3.Helper.createFormula; import static com.anjlab.sat3.SimplePermutation.createPermutation; import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue;
assertValueEquals(tier, a1); assertValueEquals(tier, b1); assertValueEquals(tier, c1); } catch (AssertionError e) { System.out.println("Formula: " + formula); System.out.println("Tier: " + tier); throw e; } } } @Test public void tryJoin2Left() throws EmptyStructureException { for (int a1 = 1; a1 <= 3; a1++) for (int b1 = 1; b1 <= 3; b1++) for (int c1 = 1; c1 <= 3; c1++) for (int a2 = 2; a2 <= 4; a2++) for (int b2 = 2; b2 <= 4; b2++) for (int c2 = 2; c2 <= 4; c2++) { if (a1 == b1 || a1 == c1 || b1 == c1) continue; if (a2 == b2 || a2 == c2 || b2 == c2) continue; Join2Left method = new Join2Left(); ITabularFormula formula = createFormula(a2, b2, c2); SimpleTier tier = new SimpleTier(a1, b1, c1);
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/Helper.java // public static ITabularFormula createFormula(int... values) // { // if (values.length%3 != 0) // { // throw new IllegalArgumentException("Number of values must be a multiple of 3"); // } // ITabularFormula formula = new SimpleFormula(); // for (int i = 0; i < values.length; i +=3) // { // SimpleTriplet triplet = new SimpleTriplet(values[i], values[i + 1], values[i + 2]); // formula.unionOrAdd(triplet); // } // return formula; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimplePermutation.java // public static IPermutation createPermutation(int... variables) // { // IPermutation permutation = new SimplePermutation(); // // for (int varName : variables) // { // permutation.add(varName); // } // // return permutation; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _101_instance = new _101(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // Path: 3-sat-core/src/test/java/com/anjlab/sat3/TestJoinMethods.java import org.junit.BeforeClass; import org.junit.Test; import static com.anjlab.sat3.Helper.createFormula; import static com.anjlab.sat3.SimplePermutation.createPermutation; import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; assertValueEquals(tier, a1); assertValueEquals(tier, b1); assertValueEquals(tier, c1); } catch (AssertionError e) { System.out.println("Formula: " + formula); System.out.println("Tier: " + tier); throw e; } } } @Test public void tryJoin2Left() throws EmptyStructureException { for (int a1 = 1; a1 <= 3; a1++) for (int b1 = 1; b1 <= 3; b1++) for (int c1 = 1; c1 <= 3; c1++) for (int a2 = 2; a2 <= 4; a2++) for (int b2 = 2; b2 <= 4; b2++) for (int c2 = 2; c2 <= 4; c2++) { if (a1 == b1 || a1 == c1 || b1 == c1) continue; if (a2 == b2 || a2 == c2 || b2 == c2) continue; Join2Left method = new Join2Left(); ITabularFormula formula = createFormula(a2, b2, c2); SimpleTier tier = new SimpleTier(a1, b1, c1);
tier.add(_000_instance);
anjlab/sat3
3-sat-core/src/main/java/com/anjlab/sat3/SimpleFormula.java
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTier.java // public static SimpleTier createCompleteTier(int a, int b, int c) // { // SimpleTier result = new SimpleTier(a, b, c); // result.keys_73516240 = -1; // Complete tier // result.size = 8; // return result; // }
import cern.colt.map.OpenIntIntHashMap; import cern.colt.map.OpenIntObjectHashMap; import cern.colt.map.OpenLongObjectHashMap; import static com.anjlab.sat3.SimpleTier.createCompleteTier; import static java.lang.Boolean.parseBoolean; import java.util.Comparator; import java.util.Properties; import cern.colt.list.ObjectArrayList;
tiersHash2 = null; int varCount = variables.size(); int tiersCount = varCount - 2; int[] variablesElements = ((SimplePermutation)variables).elements(); for (int i = 0; i < varCount; i++) { int varName = variablesElements[i]; if (!permutation.contains(varName)) { permutation.add(varName); } } for (int i = 0; i < tiers.size(); i++) { ((ITier) tiers.get(i)).inverse(); } int[] permutationElements = ((SimplePermutation)permutation).elements(); SimpleTripletPermutation buffer = new SimpleTripletPermutation(1, 2, 3); for (int i = 0; i < tiersCount; i++) { int a = permutationElements[i]; int b = permutationElements[i + 1]; int c = permutationElements[i + 2]; buffer.setCanonicalAttributes(a, b, c); if (!tiersHash3.containsKey(buffer.canonicalHashCode())) {
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTier.java // public static SimpleTier createCompleteTier(int a, int b, int c) // { // SimpleTier result = new SimpleTier(a, b, c); // result.keys_73516240 = -1; // Complete tier // result.size = 8; // return result; // } // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleFormula.java import cern.colt.map.OpenIntIntHashMap; import cern.colt.map.OpenIntObjectHashMap; import cern.colt.map.OpenLongObjectHashMap; import static com.anjlab.sat3.SimpleTier.createCompleteTier; import static java.lang.Boolean.parseBoolean; import java.util.Comparator; import java.util.Properties; import cern.colt.list.ObjectArrayList; tiersHash2 = null; int varCount = variables.size(); int tiersCount = varCount - 2; int[] variablesElements = ((SimplePermutation)variables).elements(); for (int i = 0; i < varCount; i++) { int varName = variablesElements[i]; if (!permutation.contains(varName)) { permutation.add(varName); } } for (int i = 0; i < tiers.size(); i++) { ((ITier) tiers.get(i)).inverse(); } int[] permutationElements = ((SimplePermutation)permutation).elements(); SimpleTripletPermutation buffer = new SimpleTripletPermutation(1, 2, 3); for (int i = 0; i < tiersCount; i++) { int a = permutationElements[i]; int b = permutationElements[i + 1]; int c = permutationElements[i + 2]; buffer.setCanonicalAttributes(a, b, c); if (!tiersHash3.containsKey(buffer.canonicalHashCode())) {
addTier(createCompleteTier(a, b, c));
anjlab/sat3
3-sat-core/src/test/java/com/anjlab/sat3/TestSimplePermutation.java
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimplePermutation.java // public static IPermutation createPermutation(int... variables) // { // IPermutation permutation = new SimplePermutation(); // // for (int varName : variables) // { // permutation.add(varName); // } // // return permutation; // }
import static com.anjlab.sat3.SimplePermutation.createPermutation; import static org.junit.Assert.assertEquals; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test;
Assert.assertEquals(1, stp.getCName()); } @Test public void testCanonicalName() { ITripletPermutation stp; stp = new SimpleTripletPermutation(1, 2, 3); Assert.assertArrayEquals(new int[] {1, 2, 3}, stp.getCanonicalName()); stp = new SimpleTripletPermutation(1, 3, 2); Assert.assertArrayEquals(new int[] {1, 2, 3}, stp.getCanonicalName()); stp = new SimpleTripletPermutation(2, 1, 3); Assert.assertArrayEquals(new int[] {1, 2, 3}, stp.getCanonicalName()); stp = new SimpleTripletPermutation(2, 3, 1); Assert.assertArrayEquals(new int[] {1, 2, 3}, stp.getCanonicalName()); stp = new SimpleTripletPermutation(3, 1, 2); Assert.assertArrayEquals(new int[] {1, 2, 3}, stp.getCanonicalName()); stp = new SimpleTripletPermutation(3, 2, 1); Assert.assertArrayEquals(new int[] {1, 2, 3}, stp.getCanonicalName()); } @Test public void testShiftToStart() {
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimplePermutation.java // public static IPermutation createPermutation(int... variables) // { // IPermutation permutation = new SimplePermutation(); // // for (int varName : variables) // { // permutation.add(varName); // } // // return permutation; // } // Path: 3-sat-core/src/test/java/com/anjlab/sat3/TestSimplePermutation.java import static com.anjlab.sat3.SimplePermutation.createPermutation; import static org.junit.Assert.assertEquals; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; Assert.assertEquals(1, stp.getCName()); } @Test public void testCanonicalName() { ITripletPermutation stp; stp = new SimpleTripletPermutation(1, 2, 3); Assert.assertArrayEquals(new int[] {1, 2, 3}, stp.getCanonicalName()); stp = new SimpleTripletPermutation(1, 3, 2); Assert.assertArrayEquals(new int[] {1, 2, 3}, stp.getCanonicalName()); stp = new SimpleTripletPermutation(2, 1, 3); Assert.assertArrayEquals(new int[] {1, 2, 3}, stp.getCanonicalName()); stp = new SimpleTripletPermutation(2, 3, 1); Assert.assertArrayEquals(new int[] {1, 2, 3}, stp.getCanonicalName()); stp = new SimpleTripletPermutation(3, 1, 2); Assert.assertArrayEquals(new int[] {1, 2, 3}, stp.getCanonicalName()); stp = new SimpleTripletPermutation(3, 2, 1); Assert.assertArrayEquals(new int[] {1, 2, 3}, stp.getCanonicalName()); } @Test public void testShiftToStart() {
IPermutation permutation = createPermutation(1, 2, 3, 4, 5, 6, 7, 8, 9);
anjlab/sat3
3-sat-core/src/test/java/com/anjlab/sat3/TestSimpleTriplet.java
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _011_instance = new _011(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _101_instance = new _101();
import org.junit.Test; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._011_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance; import static org.junit.Assert.assertTrue; import org.junit.Assert; import org.junit.BeforeClass;
assertTrue(t.isNotB()); assertTrue(t.isNotC()); t = new SimpleTriplet(-1, 2, 3); assertTrue(t.isNotA()); assertTrue(!t.isNotB()); assertTrue(!t.isNotC()); t = new SimpleTriplet(-1, 2, -3); assertTrue(t.isNotA()); assertTrue(!t.isNotB()); assertTrue(t.isNotC()); t = new SimpleTriplet(-1, -2, 3); assertTrue(t.isNotA()); assertTrue(t.isNotB()); assertTrue(!t.isNotC()); t = new SimpleTriplet(-1, -2, -3); assertTrue(t.isNotA()); assertTrue(t.isNotB()); assertTrue(t.isNotC()); } @Test public void testTransposeTo() { SimpleTriplet triplet = new SimpleTriplet(1, 2, -3); // triplet.add(SimpleTripletValueFactory._001_instance);
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _011_instance = new _011(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _101_instance = new _101(); // Path: 3-sat-core/src/test/java/com/anjlab/sat3/TestSimpleTriplet.java import org.junit.Test; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._011_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance; import static org.junit.Assert.assertTrue; import org.junit.Assert; import org.junit.BeforeClass; assertTrue(t.isNotB()); assertTrue(t.isNotC()); t = new SimpleTriplet(-1, 2, 3); assertTrue(t.isNotA()); assertTrue(!t.isNotB()); assertTrue(!t.isNotC()); t = new SimpleTriplet(-1, 2, -3); assertTrue(t.isNotA()); assertTrue(!t.isNotB()); assertTrue(t.isNotC()); t = new SimpleTriplet(-1, -2, 3); assertTrue(t.isNotA()); assertTrue(t.isNotB()); assertTrue(!t.isNotC()); t = new SimpleTriplet(-1, -2, -3); assertTrue(t.isNotA()); assertTrue(t.isNotB()); assertTrue(t.isNotC()); } @Test public void testTransposeTo() { SimpleTriplet triplet = new SimpleTriplet(1, 2, -3); // triplet.add(SimpleTripletValueFactory._001_instance);
triplet.add(_101_instance);
anjlab/sat3
3-sat-core/src/test/java/com/anjlab/sat3/TestSimpleTriplet.java
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _011_instance = new _011(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _101_instance = new _101();
import org.junit.Test; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._011_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance; import static org.junit.Assert.assertTrue; import org.junit.Assert; import org.junit.BeforeClass;
assertTrue(t.isNotA()); assertTrue(!t.isNotB()); assertTrue(!t.isNotC()); t = new SimpleTriplet(-1, 2, -3); assertTrue(t.isNotA()); assertTrue(!t.isNotB()); assertTrue(t.isNotC()); t = new SimpleTriplet(-1, -2, 3); assertTrue(t.isNotA()); assertTrue(t.isNotB()); assertTrue(!t.isNotC()); t = new SimpleTriplet(-1, -2, -3); assertTrue(t.isNotA()); assertTrue(t.isNotB()); assertTrue(t.isNotC()); } @Test public void testTransposeTo() { SimpleTriplet triplet = new SimpleTriplet(1, 2, -3); // triplet.add(SimpleTripletValueFactory._001_instance); triplet.add(_101_instance); triplet.transposeTo(new int[]{ 2, 1, 3 }); Assert.assertEquals(2, triplet.size());
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _011_instance = new _011(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _101_instance = new _101(); // Path: 3-sat-core/src/test/java/com/anjlab/sat3/TestSimpleTriplet.java import org.junit.Test; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._011_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance; import static org.junit.Assert.assertTrue; import org.junit.Assert; import org.junit.BeforeClass; assertTrue(t.isNotA()); assertTrue(!t.isNotB()); assertTrue(!t.isNotC()); t = new SimpleTriplet(-1, 2, -3); assertTrue(t.isNotA()); assertTrue(!t.isNotB()); assertTrue(t.isNotC()); t = new SimpleTriplet(-1, -2, 3); assertTrue(t.isNotA()); assertTrue(t.isNotB()); assertTrue(!t.isNotC()); t = new SimpleTriplet(-1, -2, -3); assertTrue(t.isNotA()); assertTrue(t.isNotB()); assertTrue(t.isNotC()); } @Test public void testTransposeTo() { SimpleTriplet triplet = new SimpleTriplet(1, 2, -3); // triplet.add(SimpleTripletValueFactory._001_instance); triplet.add(_101_instance); triplet.transposeTo(new int[]{ 2, 1, 3 }); Assert.assertEquals(2, triplet.size());
assertTrue("Should contain", triplet.contains(_001_instance));
anjlab/sat3
3-sat-core/src/test/java/com/anjlab/sat3/TestSimpleTriplet.java
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _011_instance = new _011(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _101_instance = new _101();
import org.junit.Test; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._011_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance; import static org.junit.Assert.assertTrue; import org.junit.Assert; import org.junit.BeforeClass;
assertTrue(!t.isNotB()); assertTrue(!t.isNotC()); t = new SimpleTriplet(-1, 2, -3); assertTrue(t.isNotA()); assertTrue(!t.isNotB()); assertTrue(t.isNotC()); t = new SimpleTriplet(-1, -2, 3); assertTrue(t.isNotA()); assertTrue(t.isNotB()); assertTrue(!t.isNotC()); t = new SimpleTriplet(-1, -2, -3); assertTrue(t.isNotA()); assertTrue(t.isNotB()); assertTrue(t.isNotC()); } @Test public void testTransposeTo() { SimpleTriplet triplet = new SimpleTriplet(1, 2, -3); // triplet.add(SimpleTripletValueFactory._001_instance); triplet.add(_101_instance); triplet.transposeTo(new int[]{ 2, 1, 3 }); Assert.assertEquals(2, triplet.size()); assertTrue("Should contain", triplet.contains(_001_instance));
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _011_instance = new _011(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _101_instance = new _101(); // Path: 3-sat-core/src/test/java/com/anjlab/sat3/TestSimpleTriplet.java import org.junit.Test; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._011_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance; import static org.junit.Assert.assertTrue; import org.junit.Assert; import org.junit.BeforeClass; assertTrue(!t.isNotB()); assertTrue(!t.isNotC()); t = new SimpleTriplet(-1, 2, -3); assertTrue(t.isNotA()); assertTrue(!t.isNotB()); assertTrue(t.isNotC()); t = new SimpleTriplet(-1, -2, 3); assertTrue(t.isNotA()); assertTrue(t.isNotB()); assertTrue(!t.isNotC()); t = new SimpleTriplet(-1, -2, -3); assertTrue(t.isNotA()); assertTrue(t.isNotB()); assertTrue(t.isNotC()); } @Test public void testTransposeTo() { SimpleTriplet triplet = new SimpleTriplet(1, 2, -3); // triplet.add(SimpleTripletValueFactory._001_instance); triplet.add(_101_instance); triplet.transposeTo(new int[]{ 2, 1, 3 }); Assert.assertEquals(2, triplet.size()); assertTrue("Should contain", triplet.contains(_001_instance));
assertTrue("Should contain", triplet.contains(_011_instance));
anjlab/sat3
3-sat-core/src/main/java/com/anjlab/sat3/SimpleTriplet.java
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static ITripletValue getTripletValue(int a, int b, int c) // { // // int key = ((a > 0 ? 0 : 1)) // Computing key this way will give numbering 0 4 2 6 1 5 3 7 // // + ((b > 0 ? 0 : 1) << 1) // which coincide with the tier numbering 1 2 4 8 16 32 64 128 // // + ((c > 0 ? 0 : 1) << 2); // // // Note: This should be the same as in constructor of SimpleTriplet // // int key = 1; // // if (a < 0) key <<= 4; // if (b < 0) key <<= 2; // if (c < 0) key <<= 1; // // return values[(byte)(key - 1)]; // }
import static com.anjlab.sat3.SimpleTripletValueFactory.getTripletValue;
/* * Copyright (c) 2010 AnjLab * * This file is part of * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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 * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * If not, see <http://www.gnu.org/licenses/>. */ package com.anjlab.sat3; public final class SimpleTriplet extends SimpleTier implements ITriplet { public SimpleTriplet(int a, int b, int c) { super(Math.abs(a), Math.abs(b), Math.abs(c)); size = 1; keys_73516240 = 1; if (a < 0) keys_73516240 <<= 4; if (b < 0) keys_73516240 <<= 2; if (c < 0) keys_73516240 <<= 1; } public boolean isNotA() { return (keys_73516240 & 0xF0) != 0; } public boolean isNotB() { return (keys_73516240 & 0xCC) != 0; } public boolean isNotC() { return (keys_73516240 & 0xAA) != 0; } /** * {@inheritDoc} * * <p>This implementation associates numbers according to bits in a byte:</p> * <table> * <tr><th>Values of (a,b,c)</th><th>Associated number</th><th></th></tr> * <tr><td>000</td><td>0</td> * <td rowspan='8'> * The numbering is implemented this way: * <pre> * keys_73516240 = 1; * * if (a < 0) keys_73516240 <<= 4; * if (b < 0) keys_73516240 <<= 2; * if (c < 0) keys_73516240 <<= 1; * </pre> * </td></tr> * <tr><td>001</td><td>4</td></tr> * <tr><td>010</td><td>2</td></tr> * <tr><td>011</td><td>6</td></tr> * <tr><td>100</td><td>1</td></tr> * <tr><td>101</td><td>5</td></tr> * <tr><td>110</td><td>3</td></tr> * <tr><td>111</td><td>7</td></tr> * </table> * <p>So, for example, if the third least meaningful bit in <code>keys_73516240</code> * equals to 1 then the triplet value is a value #2, which is 010. * </p> * Such implementation allows to store all possible combinations * of triplet values of a tier in a single byte. */ public byte getTierKey() { return keys_73516240; } public ITripletValue getAdjoinRightTarget1() {
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static ITripletValue getTripletValue(int a, int b, int c) // { // // int key = ((a > 0 ? 0 : 1)) // Computing key this way will give numbering 0 4 2 6 1 5 3 7 // // + ((b > 0 ? 0 : 1) << 1) // which coincide with the tier numbering 1 2 4 8 16 32 64 128 // // + ((c > 0 ? 0 : 1) << 2); // // // Note: This should be the same as in constructor of SimpleTriplet // // int key = 1; // // if (a < 0) key <<= 4; // if (b < 0) key <<= 2; // if (c < 0) key <<= 1; // // return values[(byte)(key - 1)]; // } // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTriplet.java import static com.anjlab.sat3.SimpleTripletValueFactory.getTripletValue; /* * Copyright (c) 2010 AnjLab * * This file is part of * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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 * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * If not, see <http://www.gnu.org/licenses/>. */ package com.anjlab.sat3; public final class SimpleTriplet extends SimpleTier implements ITriplet { public SimpleTriplet(int a, int b, int c) { super(Math.abs(a), Math.abs(b), Math.abs(c)); size = 1; keys_73516240 = 1; if (a < 0) keys_73516240 <<= 4; if (b < 0) keys_73516240 <<= 2; if (c < 0) keys_73516240 <<= 1; } public boolean isNotA() { return (keys_73516240 & 0xF0) != 0; } public boolean isNotB() { return (keys_73516240 & 0xCC) != 0; } public boolean isNotC() { return (keys_73516240 & 0xAA) != 0; } /** * {@inheritDoc} * * <p>This implementation associates numbers according to bits in a byte:</p> * <table> * <tr><th>Values of (a,b,c)</th><th>Associated number</th><th></th></tr> * <tr><td>000</td><td>0</td> * <td rowspan='8'> * The numbering is implemented this way: * <pre> * keys_73516240 = 1; * * if (a < 0) keys_73516240 <<= 4; * if (b < 0) keys_73516240 <<= 2; * if (c < 0) keys_73516240 <<= 1; * </pre> * </td></tr> * <tr><td>001</td><td>4</td></tr> * <tr><td>010</td><td>2</td></tr> * <tr><td>011</td><td>6</td></tr> * <tr><td>100</td><td>1</td></tr> * <tr><td>101</td><td>5</td></tr> * <tr><td>110</td><td>3</td></tr> * <tr><td>111</td><td>7</td></tr> * </table> * <p>So, for example, if the third least meaningful bit in <code>keys_73516240</code> * equals to 1 then the triplet value is a value #2, which is 010. * </p> * Such implementation allows to store all possible combinations * of triplet values of a tier in a single byte. */ public byte getTierKey() { return keys_73516240; } public ITripletValue getAdjoinRightTarget1() {
return getTripletValue(keys_73516240).getAdjoinRightTarget1();
anjlab/sat3
3-sat-core/src/test/java/com/anjlab/sat3/TestCTSOperations.java
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/Helper.java // public static void prettyPrint(ITabularFormula formula) // { // printLine('-', 50); // // StringBuilder builder = buildPrettyOutput(formula); // builder.insert(0, '\n'); // // LOGGER.info(builder.toString()); // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _010_instance = new _010(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _100_instance = new _100(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _111_instance = new _111();
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import junit.framework.Assert; import org.junit.BeforeClass; import org.junit.Test; import static com.anjlab.sat3.Helper.prettyPrint; import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._010_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._100_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._111_instance; import static org.junit.Assert.assertEquals;
/* * Copyright (c) 2010 AnjLab * * This file is part of * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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 * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * If not, see <http://www.gnu.org/licenses/>. */ package com.anjlab.sat3; public class TestCTSOperations { @BeforeClass public static void setup() { Helper.UsePrettyPrint = true; Helper.EnableAssertions = true; System.out.println(TestCTSOperations.class.getName()); } @Test public void testConcretize() { ICompactTripletsStructure s1 = (ICompactTripletsStructure) Helper.createFormula( new int[] { // x1 x2 x3 x4 1, 2, 3, // 0 0 0 -1, 2, -3, // 1 0 1 2, -3, 4, // 0 1 0 2, 3, -4 // 0 0 1 }); // VarCount: 4; ClausesCount: 4; TiersCount: 2
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/Helper.java // public static void prettyPrint(ITabularFormula formula) // { // printLine('-', 50); // // StringBuilder builder = buildPrettyOutput(formula); // builder.insert(0, '\n'); // // LOGGER.info(builder.toString()); // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _010_instance = new _010(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _100_instance = new _100(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _111_instance = new _111(); // Path: 3-sat-core/src/test/java/com/anjlab/sat3/TestCTSOperations.java import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import junit.framework.Assert; import org.junit.BeforeClass; import org.junit.Test; import static com.anjlab.sat3.Helper.prettyPrint; import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._010_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._100_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._111_instance; import static org.junit.Assert.assertEquals; /* * Copyright (c) 2010 AnjLab * * This file is part of * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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 * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * If not, see <http://www.gnu.org/licenses/>. */ package com.anjlab.sat3; public class TestCTSOperations { @BeforeClass public static void setup() { Helper.UsePrettyPrint = true; Helper.EnableAssertions = true; System.out.println(TestCTSOperations.class.getName()); } @Test public void testConcretize() { ICompactTripletsStructure s1 = (ICompactTripletsStructure) Helper.createFormula( new int[] { // x1 x2 x3 x4 1, 2, 3, // 0 0 0 -1, 2, -3, // 1 0 1 2, -3, 4, // 0 1 0 2, 3, -4 // 0 0 1 }); // VarCount: 4; ClausesCount: 4; TiersCount: 2
Helper.prettyPrint(s1);
anjlab/sat3
3-sat-core/src/test/java/com/anjlab/sat3/TestCTSOperations.java
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/Helper.java // public static void prettyPrint(ITabularFormula formula) // { // printLine('-', 50); // // StringBuilder builder = buildPrettyOutput(formula); // builder.insert(0, '\n'); // // LOGGER.info(builder.toString()); // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _010_instance = new _010(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _100_instance = new _100(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _111_instance = new _111();
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import junit.framework.Assert; import org.junit.BeforeClass; import org.junit.Test; import static com.anjlab.sat3.Helper.prettyPrint; import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._010_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._100_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._111_instance; import static org.junit.Assert.assertEquals;
/* * Copyright (c) 2010 AnjLab * * This file is part of * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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 * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * If not, see <http://www.gnu.org/licenses/>. */ package com.anjlab.sat3; public class TestCTSOperations { @BeforeClass public static void setup() { Helper.UsePrettyPrint = true; Helper.EnableAssertions = true; System.out.println(TestCTSOperations.class.getName()); } @Test public void testConcretize() { ICompactTripletsStructure s1 = (ICompactTripletsStructure) Helper.createFormula( new int[] { // x1 x2 x3 x4 1, 2, 3, // 0 0 0 -1, 2, -3, // 1 0 1 2, -3, 4, // 0 1 0 2, 3, -4 // 0 0 1 }); // VarCount: 4; ClausesCount: 4; TiersCount: 2 Helper.prettyPrint(s1); s1.concretize(3, Value.AllNegative); // x1 x2 x3 x4 // 1 0 1 // 0 1 0 // VarCount: 4; ClausesCount: 2; TiersCount: 2 Helper.prettyPrint(s1); assertEquals(2, s1.getClausesCount()); assertEquals(SimpleTripletValueFactory._101_instance, s1.getTier(0).iterator().next());
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/Helper.java // public static void prettyPrint(ITabularFormula formula) // { // printLine('-', 50); // // StringBuilder builder = buildPrettyOutput(formula); // builder.insert(0, '\n'); // // LOGGER.info(builder.toString()); // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _010_instance = new _010(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _100_instance = new _100(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _111_instance = new _111(); // Path: 3-sat-core/src/test/java/com/anjlab/sat3/TestCTSOperations.java import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import junit.framework.Assert; import org.junit.BeforeClass; import org.junit.Test; import static com.anjlab.sat3.Helper.prettyPrint; import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._010_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._100_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._111_instance; import static org.junit.Assert.assertEquals; /* * Copyright (c) 2010 AnjLab * * This file is part of * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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 * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * If not, see <http://www.gnu.org/licenses/>. */ package com.anjlab.sat3; public class TestCTSOperations { @BeforeClass public static void setup() { Helper.UsePrettyPrint = true; Helper.EnableAssertions = true; System.out.println(TestCTSOperations.class.getName()); } @Test public void testConcretize() { ICompactTripletsStructure s1 = (ICompactTripletsStructure) Helper.createFormula( new int[] { // x1 x2 x3 x4 1, 2, 3, // 0 0 0 -1, 2, -3, // 1 0 1 2, -3, 4, // 0 1 0 2, 3, -4 // 0 0 1 }); // VarCount: 4; ClausesCount: 4; TiersCount: 2 Helper.prettyPrint(s1); s1.concretize(3, Value.AllNegative); // x1 x2 x3 x4 // 1 0 1 // 0 1 0 // VarCount: 4; ClausesCount: 2; TiersCount: 2 Helper.prettyPrint(s1); assertEquals(2, s1.getClausesCount()); assertEquals(SimpleTripletValueFactory._101_instance, s1.getTier(0).iterator().next());
assertEquals(SimpleTripletValueFactory._010_instance, s1.getTier(1).iterator().next());
anjlab/sat3
3-sat-core/src/test/java/com/anjlab/sat3/TestCTSOperations.java
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/Helper.java // public static void prettyPrint(ITabularFormula formula) // { // printLine('-', 50); // // StringBuilder builder = buildPrettyOutput(formula); // builder.insert(0, '\n'); // // LOGGER.info(builder.toString()); // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _010_instance = new _010(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _100_instance = new _100(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _111_instance = new _111();
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import junit.framework.Assert; import org.junit.BeforeClass; import org.junit.Test; import static com.anjlab.sat3.Helper.prettyPrint; import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._010_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._100_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._111_instance; import static org.junit.Assert.assertEquals;
s2.cleanup(); assertTrue(!s2.isEmpty()); ICompactTripletsStructure s = (ICompactTripletsStructure) Helper.createFormula(1, 2, 3, -2, 3, 4); s.cleanup(); assertTrue(s.isEmpty()); s2.union(s); assertEquals(2, s2.getClausesCount()); } @Test public void testCleanupFormulaThatHasEmptyTier() { ICompactTripletsStructure s = (ICompactTripletsStructure) Helper.createFormula( new int[] { // a b c d e 1, 2, 3, // 0 0 0 2, 3, 4, // 0 0 0 3, 4, 5 // VarCount: 5; ClausesCount: 2; TiersCount: 3 });
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/Helper.java // public static void prettyPrint(ITabularFormula formula) // { // printLine('-', 50); // // StringBuilder builder = buildPrettyOutput(formula); // builder.insert(0, '\n'); // // LOGGER.info(builder.toString()); // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _010_instance = new _010(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _100_instance = new _100(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _111_instance = new _111(); // Path: 3-sat-core/src/test/java/com/anjlab/sat3/TestCTSOperations.java import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import junit.framework.Assert; import org.junit.BeforeClass; import org.junit.Test; import static com.anjlab.sat3.Helper.prettyPrint; import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._010_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._100_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._111_instance; import static org.junit.Assert.assertEquals; s2.cleanup(); assertTrue(!s2.isEmpty()); ICompactTripletsStructure s = (ICompactTripletsStructure) Helper.createFormula(1, 2, 3, -2, 3, 4); s.cleanup(); assertTrue(s.isEmpty()); s2.union(s); assertEquals(2, s2.getClausesCount()); } @Test public void testCleanupFormulaThatHasEmptyTier() { ICompactTripletsStructure s = (ICompactTripletsStructure) Helper.createFormula( new int[] { // a b c d e 1, 2, 3, // 0 0 0 2, 3, 4, // 0 0 0 3, 4, 5 // VarCount: 5; ClausesCount: 2; TiersCount: 3 });
s.getTier(1).remove(SimpleTripletValueFactory._000_instance);
anjlab/sat3
3-sat-core/src/test/java/com/anjlab/sat3/TestCTSOperations.java
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/Helper.java // public static void prettyPrint(ITabularFormula formula) // { // printLine('-', 50); // // StringBuilder builder = buildPrettyOutput(formula); // builder.insert(0, '\n'); // // LOGGER.info(builder.toString()); // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _010_instance = new _010(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _100_instance = new _100(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _111_instance = new _111();
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import junit.framework.Assert; import org.junit.BeforeClass; import org.junit.Test; import static com.anjlab.sat3.Helper.prettyPrint; import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._010_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._100_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._111_instance; import static org.junit.Assert.assertEquals;
Helper.createFormula( new int[] { // a b c d e 1, 2, 3, // 0 0 0 -1, 2, 3, // 1 0 0 -1, 2, -3, // 1 0 1 2, 3, 4, // 0 0 0 2, -3, 4, // 0 1 0 2, -3, -4, // 0 1 1 3, 4, 5, // 0 0 0 -3, 4, 5, // 1 0 0 -3, -4, -5, // 1 1 1 }); // VarCount: 5; ClausesCount: 9; TiersCount: 3 prettyPrint(s2); s1.intersect(s2); // a b c d e // 1 0 0 // 0 0 0 // 0 0 0 // VarCount: 5; ClausesCount: 3; TiersCount: 3 prettyPrint(s1); assertEquals(3, s1.getClausesCount()); ITier _123 = s1.getTier(0); assertEquals(1, _123.size());
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/Helper.java // public static void prettyPrint(ITabularFormula formula) // { // printLine('-', 50); // // StringBuilder builder = buildPrettyOutput(formula); // builder.insert(0, '\n'); // // LOGGER.info(builder.toString()); // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _010_instance = new _010(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _100_instance = new _100(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _111_instance = new _111(); // Path: 3-sat-core/src/test/java/com/anjlab/sat3/TestCTSOperations.java import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import junit.framework.Assert; import org.junit.BeforeClass; import org.junit.Test; import static com.anjlab.sat3.Helper.prettyPrint; import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._010_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._100_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._111_instance; import static org.junit.Assert.assertEquals; Helper.createFormula( new int[] { // a b c d e 1, 2, 3, // 0 0 0 -1, 2, 3, // 1 0 0 -1, 2, -3, // 1 0 1 2, 3, 4, // 0 0 0 2, -3, 4, // 0 1 0 2, -3, -4, // 0 1 1 3, 4, 5, // 0 0 0 -3, 4, 5, // 1 0 0 -3, -4, -5, // 1 1 1 }); // VarCount: 5; ClausesCount: 9; TiersCount: 3 prettyPrint(s2); s1.intersect(s2); // a b c d e // 1 0 0 // 0 0 0 // 0 0 0 // VarCount: 5; ClausesCount: 3; TiersCount: 3 prettyPrint(s1); assertEquals(3, s1.getClausesCount()); ITier _123 = s1.getTier(0); assertEquals(1, _123.size());
assertTrue(_123.contains(_100_instance));
anjlab/sat3
3-sat-core/src/test/java/com/anjlab/sat3/TestCTSOperations.java
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/Helper.java // public static void prettyPrint(ITabularFormula formula) // { // printLine('-', 50); // // StringBuilder builder = buildPrettyOutput(formula); // builder.insert(0, '\n'); // // LOGGER.info(builder.toString()); // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _010_instance = new _010(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _100_instance = new _100(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _111_instance = new _111();
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import junit.framework.Assert; import org.junit.BeforeClass; import org.junit.Test; import static com.anjlab.sat3.Helper.prettyPrint; import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._010_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._100_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._111_instance; import static org.junit.Assert.assertEquals;
} @Test public void testCompleteCTF2CTS() throws Exception { ITabularFormula formula = Helper.createFormula( new int[] { 1, 2, 3, 1, -2, 3, -1, 2, 3, 2, 3, 4, 2, -3, 4, -2, -3, -4 }); Helper.prettyPrint(formula); formula.complete(SimplePermutation.createPermutation( new int[] {1, 2, 3, 4, 5, 6})); assertEquals(6, formula.getVarCount()); Helper.prettyPrint(formula); assertTrue(!formula.getTier(0).contains(_000_instance)); assertTrue(!formula.getTier(0).contains(_010_instance)); assertTrue(!formula.getTier(0).contains(_100_instance)); assertEquals(5, formula.getTier(0).size()); assertTrue(!formula.getTier(1).contains(_000_instance)); assertTrue(!formula.getTier(1).contains(_010_instance));
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/Helper.java // public static void prettyPrint(ITabularFormula formula) // { // printLine('-', 50); // // StringBuilder builder = buildPrettyOutput(formula); // builder.insert(0, '\n'); // // LOGGER.info(builder.toString()); // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _010_instance = new _010(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _100_instance = new _100(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _111_instance = new _111(); // Path: 3-sat-core/src/test/java/com/anjlab/sat3/TestCTSOperations.java import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import junit.framework.Assert; import org.junit.BeforeClass; import org.junit.Test; import static com.anjlab.sat3.Helper.prettyPrint; import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._010_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._100_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._111_instance; import static org.junit.Assert.assertEquals; } @Test public void testCompleteCTF2CTS() throws Exception { ITabularFormula formula = Helper.createFormula( new int[] { 1, 2, 3, 1, -2, 3, -1, 2, 3, 2, 3, 4, 2, -3, 4, -2, -3, -4 }); Helper.prettyPrint(formula); formula.complete(SimplePermutation.createPermutation( new int[] {1, 2, 3, 4, 5, 6})); assertEquals(6, formula.getVarCount()); Helper.prettyPrint(formula); assertTrue(!formula.getTier(0).contains(_000_instance)); assertTrue(!formula.getTier(0).contains(_010_instance)); assertTrue(!formula.getTier(0).contains(_100_instance)); assertEquals(5, formula.getTier(0).size()); assertTrue(!formula.getTier(1).contains(_000_instance)); assertTrue(!formula.getTier(1).contains(_010_instance));
assertTrue(!formula.getTier(1).contains(_111_instance));
anjlab/sat3
3-sat-core/src/test/java/com/anjlab/sat3/TestCTSOperations.java
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/Helper.java // public static void prettyPrint(ITabularFormula formula) // { // printLine('-', 50); // // StringBuilder builder = buildPrettyOutput(formula); // builder.insert(0, '\n'); // // LOGGER.info(builder.toString()); // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _010_instance = new _010(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _100_instance = new _100(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _111_instance = new _111();
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import junit.framework.Assert; import org.junit.BeforeClass; import org.junit.Test; import static com.anjlab.sat3.Helper.prettyPrint; import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._010_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._100_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._111_instance; import static org.junit.Assert.assertEquals;
Helper.prettyPrint(formula); assertTrue(!formula.getTier(0).contains(_000_instance)); assertTrue(!formula.getTier(0).contains(_010_instance)); assertTrue(!formula.getTier(0).contains(_100_instance)); assertEquals(5, formula.getTier(0).size()); assertTrue(!formula.getTier(1).contains(_000_instance)); assertTrue(!formula.getTier(1).contains(_010_instance)); assertTrue(!formula.getTier(1).contains(_111_instance)); assertEquals(4, formula.getTier(1).size()); // Cleanup assertEquals(8, formula.getTier(2).size()); assertEquals(8, formula.getTier(2).size()); } @Test public void testCleanupFromTo() { SimpleFormula formula = (SimpleFormula) Helper.createFormula(1, 2, 3, 1, 2, -3, 1, -2, -3, 2, -3, -4, -2, -3, 4, 2, 3, -4, 3, -4, 5, -3, -4, -5, -3, 4, 5); Helper.prettyPrint(formula);
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/Helper.java // public static void prettyPrint(ITabularFormula formula) // { // printLine('-', 50); // // StringBuilder builder = buildPrettyOutput(formula); // builder.insert(0, '\n'); // // LOGGER.info(builder.toString()); // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _010_instance = new _010(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _100_instance = new _100(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _111_instance = new _111(); // Path: 3-sat-core/src/test/java/com/anjlab/sat3/TestCTSOperations.java import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import junit.framework.Assert; import org.junit.BeforeClass; import org.junit.Test; import static com.anjlab.sat3.Helper.prettyPrint; import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._010_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._100_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._111_instance; import static org.junit.Assert.assertEquals; Helper.prettyPrint(formula); assertTrue(!formula.getTier(0).contains(_000_instance)); assertTrue(!formula.getTier(0).contains(_010_instance)); assertTrue(!formula.getTier(0).contains(_100_instance)); assertEquals(5, formula.getTier(0).size()); assertTrue(!formula.getTier(1).contains(_000_instance)); assertTrue(!formula.getTier(1).contains(_010_instance)); assertTrue(!formula.getTier(1).contains(_111_instance)); assertEquals(4, formula.getTier(1).size()); // Cleanup assertEquals(8, formula.getTier(2).size()); assertEquals(8, formula.getTier(2).size()); } @Test public void testCleanupFromTo() { SimpleFormula formula = (SimpleFormula) Helper.createFormula(1, 2, 3, 1, 2, -3, 1, -2, -3, 2, -3, -4, -2, -3, 4, 2, 3, -4, 3, -4, 5, -3, -4, -5, -3, 4, 5); Helper.prettyPrint(formula);
formula.getTier(1).remove(_001_instance);
anjlab/sat3
3-sat-core/src/test/java/com/anjlab/sat3/TestSimpleTier.java
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _010_instance = new _010(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _011_instance = new _011(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _100_instance = new _100(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _101_instance = new _101(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _110_instance = new _110(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _111_instance = new _111();
import static com.anjlab.sat3.SimpleTripletValueFactory._111_instance; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import org.junit.BeforeClass; import org.junit.Test; import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._010_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._011_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._100_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._110_instance;
/* * Copyright (c) 2010 AnjLab * * This file is part of * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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 * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * If not, see <http://www.gnu.org/licenses/>. */ package com.anjlab.sat3; public class TestSimpleTier { @BeforeClass public static void setup() { Helper.UsePrettyPrint = true; Helper.EnableAssertions = true; System.out.println(TestSimpleTier.class.getName()); } @Test public void testAddSameTripletSeveralTimes() { ITier tier = new SimpleTier(1, 2, 3);
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _010_instance = new _010(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _011_instance = new _011(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _100_instance = new _100(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _101_instance = new _101(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _110_instance = new _110(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _111_instance = new _111(); // Path: 3-sat-core/src/test/java/com/anjlab/sat3/TestSimpleTier.java import static com.anjlab.sat3.SimpleTripletValueFactory._111_instance; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import org.junit.BeforeClass; import org.junit.Test; import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._010_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._011_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._100_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._110_instance; /* * Copyright (c) 2010 AnjLab * * This file is part of * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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 * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * If not, see <http://www.gnu.org/licenses/>. */ package com.anjlab.sat3; public class TestSimpleTier { @BeforeClass public static void setup() { Helper.UsePrettyPrint = true; Helper.EnableAssertions = true; System.out.println(TestSimpleTier.class.getName()); } @Test public void testAddSameTripletSeveralTimes() { ITier tier = new SimpleTier(1, 2, 3);
tier.add(_000_instance);
anjlab/sat3
3-sat-core/src/test/java/com/anjlab/sat3/TestSimpleTier.java
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _010_instance = new _010(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _011_instance = new _011(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _100_instance = new _100(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _101_instance = new _101(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _110_instance = new _110(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _111_instance = new _111();
import static com.anjlab.sat3.SimpleTripletValueFactory._111_instance; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import org.junit.BeforeClass; import org.junit.Test; import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._010_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._011_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._100_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._110_instance;
/* * Copyright (c) 2010 AnjLab * * This file is part of * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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 * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * If not, see <http://www.gnu.org/licenses/>. */ package com.anjlab.sat3; public class TestSimpleTier { @BeforeClass public static void setup() { Helper.UsePrettyPrint = true; Helper.EnableAssertions = true; System.out.println(TestSimpleTier.class.getName()); } @Test public void testAddSameTripletSeveralTimes() { ITier tier = new SimpleTier(1, 2, 3); tier.add(_000_instance); tier.add(_000_instance); tier.add(_000_instance);
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _010_instance = new _010(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _011_instance = new _011(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _100_instance = new _100(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _101_instance = new _101(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _110_instance = new _110(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _111_instance = new _111(); // Path: 3-sat-core/src/test/java/com/anjlab/sat3/TestSimpleTier.java import static com.anjlab.sat3.SimpleTripletValueFactory._111_instance; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import org.junit.BeforeClass; import org.junit.Test; import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._010_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._011_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._100_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._110_instance; /* * Copyright (c) 2010 AnjLab * * This file is part of * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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 * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * If not, see <http://www.gnu.org/licenses/>. */ package com.anjlab.sat3; public class TestSimpleTier { @BeforeClass public static void setup() { Helper.UsePrettyPrint = true; Helper.EnableAssertions = true; System.out.println(TestSimpleTier.class.getName()); } @Test public void testAddSameTripletSeveralTimes() { ITier tier = new SimpleTier(1, 2, 3); tier.add(_000_instance); tier.add(_000_instance); tier.add(_000_instance);
tier.add(_001_instance);
anjlab/sat3
3-sat-core/src/test/java/com/anjlab/sat3/TestSimpleTier.java
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _010_instance = new _010(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _011_instance = new _011(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _100_instance = new _100(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _101_instance = new _101(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _110_instance = new _110(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _111_instance = new _111();
import static com.anjlab.sat3.SimpleTripletValueFactory._111_instance; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import org.junit.BeforeClass; import org.junit.Test; import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._010_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._011_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._100_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._110_instance;
/* * Copyright (c) 2010 AnjLab * * This file is part of * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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 * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * If not, see <http://www.gnu.org/licenses/>. */ package com.anjlab.sat3; public class TestSimpleTier { @BeforeClass public static void setup() { Helper.UsePrettyPrint = true; Helper.EnableAssertions = true; System.out.println(TestSimpleTier.class.getName()); } @Test public void testAddSameTripletSeveralTimes() { ITier tier = new SimpleTier(1, 2, 3); tier.add(_000_instance); tier.add(_000_instance); tier.add(_000_instance); tier.add(_001_instance); // Adding same triplet several times should result in adding only one triplet assertEquals(2, tier.size()); } @Test public void testRemoveTriplet() { ITier tier = new SimpleTier(1, 2, 3); tier.add(_000_instance);
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _010_instance = new _010(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _011_instance = new _011(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _100_instance = new _100(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _101_instance = new _101(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _110_instance = new _110(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _111_instance = new _111(); // Path: 3-sat-core/src/test/java/com/anjlab/sat3/TestSimpleTier.java import static com.anjlab.sat3.SimpleTripletValueFactory._111_instance; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import org.junit.BeforeClass; import org.junit.Test; import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._010_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._011_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._100_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._110_instance; /* * Copyright (c) 2010 AnjLab * * This file is part of * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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 * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * If not, see <http://www.gnu.org/licenses/>. */ package com.anjlab.sat3; public class TestSimpleTier { @BeforeClass public static void setup() { Helper.UsePrettyPrint = true; Helper.EnableAssertions = true; System.out.println(TestSimpleTier.class.getName()); } @Test public void testAddSameTripletSeveralTimes() { ITier tier = new SimpleTier(1, 2, 3); tier.add(_000_instance); tier.add(_000_instance); tier.add(_000_instance); tier.add(_001_instance); // Adding same triplet several times should result in adding only one triplet assertEquals(2, tier.size()); } @Test public void testRemoveTriplet() { ITier tier = new SimpleTier(1, 2, 3); tier.add(_000_instance);
tier.add(_010_instance);
anjlab/sat3
3-sat-core/src/test/java/com/anjlab/sat3/TestSimpleTier.java
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _010_instance = new _010(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _011_instance = new _011(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _100_instance = new _100(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _101_instance = new _101(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _110_instance = new _110(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _111_instance = new _111();
import static com.anjlab.sat3.SimpleTripletValueFactory._111_instance; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import org.junit.BeforeClass; import org.junit.Test; import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._010_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._011_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._100_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._110_instance;
/* * Copyright (c) 2010 AnjLab * * This file is part of * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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 * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * If not, see <http://www.gnu.org/licenses/>. */ package com.anjlab.sat3; public class TestSimpleTier { @BeforeClass public static void setup() { Helper.UsePrettyPrint = true; Helper.EnableAssertions = true; System.out.println(TestSimpleTier.class.getName()); } @Test public void testAddSameTripletSeveralTimes() { ITier tier = new SimpleTier(1, 2, 3); tier.add(_000_instance); tier.add(_000_instance); tier.add(_000_instance); tier.add(_001_instance); // Adding same triplet several times should result in adding only one triplet assertEquals(2, tier.size()); } @Test public void testRemoveTriplet() { ITier tier = new SimpleTier(1, 2, 3); tier.add(_000_instance); tier.add(_010_instance);
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _010_instance = new _010(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _011_instance = new _011(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _100_instance = new _100(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _101_instance = new _101(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _110_instance = new _110(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _111_instance = new _111(); // Path: 3-sat-core/src/test/java/com/anjlab/sat3/TestSimpleTier.java import static com.anjlab.sat3.SimpleTripletValueFactory._111_instance; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import org.junit.BeforeClass; import org.junit.Test; import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._010_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._011_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._100_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._110_instance; /* * Copyright (c) 2010 AnjLab * * This file is part of * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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 * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * If not, see <http://www.gnu.org/licenses/>. */ package com.anjlab.sat3; public class TestSimpleTier { @BeforeClass public static void setup() { Helper.UsePrettyPrint = true; Helper.EnableAssertions = true; System.out.println(TestSimpleTier.class.getName()); } @Test public void testAddSameTripletSeveralTimes() { ITier tier = new SimpleTier(1, 2, 3); tier.add(_000_instance); tier.add(_000_instance); tier.add(_000_instance); tier.add(_001_instance); // Adding same triplet several times should result in adding only one triplet assertEquals(2, tier.size()); } @Test public void testRemoveTriplet() { ITier tier = new SimpleTier(1, 2, 3); tier.add(_000_instance); tier.add(_010_instance);
tier.add(_100_instance);
anjlab/sat3
3-sat-core/src/test/java/com/anjlab/sat3/TestSimpleTier.java
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _010_instance = new _010(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _011_instance = new _011(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _100_instance = new _100(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _101_instance = new _101(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _110_instance = new _110(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _111_instance = new _111();
import static com.anjlab.sat3.SimpleTripletValueFactory._111_instance; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import org.junit.BeforeClass; import org.junit.Test; import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._010_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._011_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._100_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._110_instance;
/* * Copyright (c) 2010 AnjLab * * This file is part of * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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 * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * If not, see <http://www.gnu.org/licenses/>. */ package com.anjlab.sat3; public class TestSimpleTier { @BeforeClass public static void setup() { Helper.UsePrettyPrint = true; Helper.EnableAssertions = true; System.out.println(TestSimpleTier.class.getName()); } @Test public void testAddSameTripletSeveralTimes() { ITier tier = new SimpleTier(1, 2, 3); tier.add(_000_instance); tier.add(_000_instance); tier.add(_000_instance); tier.add(_001_instance); // Adding same triplet several times should result in adding only one triplet assertEquals(2, tier.size()); } @Test public void testRemoveTriplet() { ITier tier = new SimpleTier(1, 2, 3); tier.add(_000_instance); tier.add(_010_instance); tier.add(_100_instance);
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _010_instance = new _010(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _011_instance = new _011(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _100_instance = new _100(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _101_instance = new _101(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _110_instance = new _110(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _111_instance = new _111(); // Path: 3-sat-core/src/test/java/com/anjlab/sat3/TestSimpleTier.java import static com.anjlab.sat3.SimpleTripletValueFactory._111_instance; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import org.junit.BeforeClass; import org.junit.Test; import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._010_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._011_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._100_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._110_instance; /* * Copyright (c) 2010 AnjLab * * This file is part of * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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 * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * If not, see <http://www.gnu.org/licenses/>. */ package com.anjlab.sat3; public class TestSimpleTier { @BeforeClass public static void setup() { Helper.UsePrettyPrint = true; Helper.EnableAssertions = true; System.out.println(TestSimpleTier.class.getName()); } @Test public void testAddSameTripletSeveralTimes() { ITier tier = new SimpleTier(1, 2, 3); tier.add(_000_instance); tier.add(_000_instance); tier.add(_000_instance); tier.add(_001_instance); // Adding same triplet several times should result in adding only one triplet assertEquals(2, tier.size()); } @Test public void testRemoveTriplet() { ITier tier = new SimpleTier(1, 2, 3); tier.add(_000_instance); tier.add(_010_instance); tier.add(_100_instance);
tier.add(_011_instance);
anjlab/sat3
3-sat-core/src/test/java/com/anjlab/sat3/TestSimpleTier.java
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _010_instance = new _010(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _011_instance = new _011(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _100_instance = new _100(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _101_instance = new _101(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _110_instance = new _110(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _111_instance = new _111();
import static com.anjlab.sat3.SimpleTripletValueFactory._111_instance; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import org.junit.BeforeClass; import org.junit.Test; import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._010_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._011_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._100_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._110_instance;
assertEquals(4, tier.size()); tier.remove(_100_instance); assertEquals(3, tier.size()); } @Test public void testTripletsIterator() { ITier tier = new SimpleTier(1, 2, 3); tier.add(_000_instance); tier.add(_010_instance); for (ITripletValue tripletValue : tier) { System.out.println(tripletValue); } } @Test public void testFullTierIterator() { ITier tier = new SimpleTier(1, 2, 3); tier.add(_000_instance); tier.add(_001_instance); tier.add(_010_instance); tier.add(_011_instance); tier.add(_100_instance);
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _010_instance = new _010(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _011_instance = new _011(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _100_instance = new _100(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _101_instance = new _101(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _110_instance = new _110(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _111_instance = new _111(); // Path: 3-sat-core/src/test/java/com/anjlab/sat3/TestSimpleTier.java import static com.anjlab.sat3.SimpleTripletValueFactory._111_instance; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import org.junit.BeforeClass; import org.junit.Test; import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._010_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._011_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._100_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._110_instance; assertEquals(4, tier.size()); tier.remove(_100_instance); assertEquals(3, tier.size()); } @Test public void testTripletsIterator() { ITier tier = new SimpleTier(1, 2, 3); tier.add(_000_instance); tier.add(_010_instance); for (ITripletValue tripletValue : tier) { System.out.println(tripletValue); } } @Test public void testFullTierIterator() { ITier tier = new SimpleTier(1, 2, 3); tier.add(_000_instance); tier.add(_001_instance); tier.add(_010_instance); tier.add(_011_instance); tier.add(_100_instance);
tier.add(_101_instance);
anjlab/sat3
3-sat-core/src/test/java/com/anjlab/sat3/TestSimpleTier.java
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _010_instance = new _010(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _011_instance = new _011(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _100_instance = new _100(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _101_instance = new _101(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _110_instance = new _110(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _111_instance = new _111();
import static com.anjlab.sat3.SimpleTripletValueFactory._111_instance; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import org.junit.BeforeClass; import org.junit.Test; import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._010_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._011_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._100_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._110_instance;
tier.remove(_100_instance); assertEquals(3, tier.size()); } @Test public void testTripletsIterator() { ITier tier = new SimpleTier(1, 2, 3); tier.add(_000_instance); tier.add(_010_instance); for (ITripletValue tripletValue : tier) { System.out.println(tripletValue); } } @Test public void testFullTierIterator() { ITier tier = new SimpleTier(1, 2, 3); tier.add(_000_instance); tier.add(_001_instance); tier.add(_010_instance); tier.add(_011_instance); tier.add(_100_instance); tier.add(_101_instance);
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _010_instance = new _010(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _011_instance = new _011(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _100_instance = new _100(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _101_instance = new _101(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _110_instance = new _110(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _111_instance = new _111(); // Path: 3-sat-core/src/test/java/com/anjlab/sat3/TestSimpleTier.java import static com.anjlab.sat3.SimpleTripletValueFactory._111_instance; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import org.junit.BeforeClass; import org.junit.Test; import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._010_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._011_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._100_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._110_instance; tier.remove(_100_instance); assertEquals(3, tier.size()); } @Test public void testTripletsIterator() { ITier tier = new SimpleTier(1, 2, 3); tier.add(_000_instance); tier.add(_010_instance); for (ITripletValue tripletValue : tier) { System.out.println(tripletValue); } } @Test public void testFullTierIterator() { ITier tier = new SimpleTier(1, 2, 3); tier.add(_000_instance); tier.add(_001_instance); tier.add(_010_instance); tier.add(_011_instance); tier.add(_100_instance); tier.add(_101_instance);
tier.add(_110_instance);
anjlab/sat3
3-sat-core/src/test/java/com/anjlab/sat3/TestSimpleTier.java
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _010_instance = new _010(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _011_instance = new _011(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _100_instance = new _100(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _101_instance = new _101(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _110_instance = new _110(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _111_instance = new _111();
import static com.anjlab.sat3.SimpleTripletValueFactory._111_instance; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import org.junit.BeforeClass; import org.junit.Test; import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._010_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._011_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._100_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._110_instance;
tier.remove(_100_instance); assertEquals(3, tier.size()); } @Test public void testTripletsIterator() { ITier tier = new SimpleTier(1, 2, 3); tier.add(_000_instance); tier.add(_010_instance); for (ITripletValue tripletValue : tier) { System.out.println(tripletValue); } } @Test public void testFullTierIterator() { ITier tier = new SimpleTier(1, 2, 3); tier.add(_000_instance); tier.add(_001_instance); tier.add(_010_instance); tier.add(_011_instance); tier.add(_100_instance); tier.add(_101_instance); tier.add(_110_instance);
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _000_instance = new _000(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _001_instance = new _001(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _010_instance = new _010(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _011_instance = new _011(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _100_instance = new _100(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _101_instance = new _101(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _110_instance = new _110(); // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _111_instance = new _111(); // Path: 3-sat-core/src/test/java/com/anjlab/sat3/TestSimpleTier.java import static com.anjlab.sat3.SimpleTripletValueFactory._111_instance; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import org.junit.BeforeClass; import org.junit.Test; import static com.anjlab.sat3.SimpleTripletValueFactory._000_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._001_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._010_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._011_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._100_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._101_instance; import static com.anjlab.sat3.SimpleTripletValueFactory._110_instance; tier.remove(_100_instance); assertEquals(3, tier.size()); } @Test public void testTripletsIterator() { ITier tier = new SimpleTier(1, 2, 3); tier.add(_000_instance); tier.add(_010_instance); for (ITripletValue tripletValue : tier) { System.out.println(tripletValue); } } @Test public void testFullTierIterator() { ITier tier = new SimpleTier(1, 2, 3); tier.add(_000_instance); tier.add(_001_instance); tier.add(_010_instance); tier.add(_011_instance); tier.add(_100_instance); tier.add(_101_instance); tier.add(_110_instance);
tier.add(_111_instance);
anjlab/sat3
3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static boolean canTranspose(ITabularFormula formula, ITier tier, int varName1, int varName2) // { // ITier otherTier = ensureTheOnlyTierWithVariableExistsAndGetTheTier(formula, varName1); // // if (otherTier != tier) // { // return false; // } // otherTier = ensureTheOnlyTierWithVariableExistsAndGetTheTier(formula, varName2); // if (otherTier != tier) // { // return false; // } // return true; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static boolean endsWith(ITabularFormula formula, int varName1, int varName2) // { // IPermutation permutation = formula.getPermutation(); // // int permutationSize = permutation.size(); // // return permutation.get(permutationSize - 2) == varName1 // && permutation.get(permutationSize - 1) == varName2; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static ITier ensureTheOnlyTierWithVariableExistsAndGetTheTier(ITabularFormula formula, int varName) // { // ObjectArrayList tiers = formula.findTiersFor(varName); // if (tiers == null) // { // return null; // } // if (tiers.size() == 1) // { // return (ITier) tiers.get(0); // } // return null; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static ITier ensureTheOnlyTierWithVariablesExistsAndGetTheTier(ITabularFormula formula, int varName1, int varName2) // { // ObjectArrayList tiers = formula.findTiersFor(varName1, varName2); // if (tiers == null) // { // return null; // } // if (tiers.size() == 1) // { // return (ITier) tiers.get(0); // } // return null; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static boolean startsWith(ITabularFormula formula, int varName) // { // return formula.getPermutation().get(0) == varName; // }
import static com.anjlab.sat3.Join2BetweenTiers.canTranspose; import static com.anjlab.sat3.JoinMethods.endsWith; import static com.anjlab.sat3.JoinMethods.ensureTheOnlyTierWithVariableExistsAndGetTheTier; import static com.anjlab.sat3.JoinMethods.ensureTheOnlyTierWithVariablesExistsAndGetTheTier; import static com.anjlab.sat3.JoinMethods.startsWith; import cern.colt.list.ObjectArrayList;
/* * Copyright (c) 2010 AnjLab * * This file is part of * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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 * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * If not, see <http://www.gnu.org/licenses/>. */ package com.anjlab.sat3; public class JoinMethods { private static final IJoinMethod[] joinMethods = new IJoinMethod[] { // The order matters new Join3AsIs(), new Join3BetweenTiers(), new Join2BetweenTiers(), new Join2Right(), new Join2Left(), new Join1Right(), new Join1Left(), new Join0(), }; public static IJoinMethod[] getMethods() { return joinMethods; } public static boolean missingAll(ITabularFormula formula, int varName1, int varName2) { IPermutation permutation = formula.getPermutation(); return !permutation.contains(varName1) && !permutation.contains(varName2); }
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static boolean canTranspose(ITabularFormula formula, ITier tier, int varName1, int varName2) // { // ITier otherTier = ensureTheOnlyTierWithVariableExistsAndGetTheTier(formula, varName1); // // if (otherTier != tier) // { // return false; // } // otherTier = ensureTheOnlyTierWithVariableExistsAndGetTheTier(formula, varName2); // if (otherTier != tier) // { // return false; // } // return true; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static boolean endsWith(ITabularFormula formula, int varName1, int varName2) // { // IPermutation permutation = formula.getPermutation(); // // int permutationSize = permutation.size(); // // return permutation.get(permutationSize - 2) == varName1 // && permutation.get(permutationSize - 1) == varName2; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static ITier ensureTheOnlyTierWithVariableExistsAndGetTheTier(ITabularFormula formula, int varName) // { // ObjectArrayList tiers = formula.findTiersFor(varName); // if (tiers == null) // { // return null; // } // if (tiers.size() == 1) // { // return (ITier) tiers.get(0); // } // return null; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static ITier ensureTheOnlyTierWithVariablesExistsAndGetTheTier(ITabularFormula formula, int varName1, int varName2) // { // ObjectArrayList tiers = formula.findTiersFor(varName1, varName2); // if (tiers == null) // { // return null; // } // if (tiers.size() == 1) // { // return (ITier) tiers.get(0); // } // return null; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static boolean startsWith(ITabularFormula formula, int varName) // { // return formula.getPermutation().get(0) == varName; // } // Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java import static com.anjlab.sat3.Join2BetweenTiers.canTranspose; import static com.anjlab.sat3.JoinMethods.endsWith; import static com.anjlab.sat3.JoinMethods.ensureTheOnlyTierWithVariableExistsAndGetTheTier; import static com.anjlab.sat3.JoinMethods.ensureTheOnlyTierWithVariablesExistsAndGetTheTier; import static com.anjlab.sat3.JoinMethods.startsWith; import cern.colt.list.ObjectArrayList; /* * Copyright (c) 2010 AnjLab * * This file is part of * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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 * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * If not, see <http://www.gnu.org/licenses/>. */ package com.anjlab.sat3; public class JoinMethods { private static final IJoinMethod[] joinMethods = new IJoinMethod[] { // The order matters new Join3AsIs(), new Join3BetweenTiers(), new Join2BetweenTiers(), new Join2Right(), new Join2Left(), new Join1Right(), new Join1Left(), new Join0(), }; public static IJoinMethod[] getMethods() { return joinMethods; } public static boolean missingAll(ITabularFormula formula, int varName1, int varName2) { IPermutation permutation = formula.getPermutation(); return !permutation.contains(varName1) && !permutation.contains(varName2); }
public static boolean startsWith(ITabularFormula formula, int varName)
anjlab/sat3
3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static boolean canTranspose(ITabularFormula formula, ITier tier, int varName1, int varName2) // { // ITier otherTier = ensureTheOnlyTierWithVariableExistsAndGetTheTier(formula, varName1); // // if (otherTier != tier) // { // return false; // } // otherTier = ensureTheOnlyTierWithVariableExistsAndGetTheTier(formula, varName2); // if (otherTier != tier) // { // return false; // } // return true; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static boolean endsWith(ITabularFormula formula, int varName1, int varName2) // { // IPermutation permutation = formula.getPermutation(); // // int permutationSize = permutation.size(); // // return permutation.get(permutationSize - 2) == varName1 // && permutation.get(permutationSize - 1) == varName2; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static ITier ensureTheOnlyTierWithVariableExistsAndGetTheTier(ITabularFormula formula, int varName) // { // ObjectArrayList tiers = formula.findTiersFor(varName); // if (tiers == null) // { // return null; // } // if (tiers.size() == 1) // { // return (ITier) tiers.get(0); // } // return null; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static ITier ensureTheOnlyTierWithVariablesExistsAndGetTheTier(ITabularFormula formula, int varName1, int varName2) // { // ObjectArrayList tiers = formula.findTiersFor(varName1, varName2); // if (tiers == null) // { // return null; // } // if (tiers.size() == 1) // { // return (ITier) tiers.get(0); // } // return null; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static boolean startsWith(ITabularFormula formula, int varName) // { // return formula.getPermutation().get(0) == varName; // }
import static com.anjlab.sat3.Join2BetweenTiers.canTranspose; import static com.anjlab.sat3.JoinMethods.endsWith; import static com.anjlab.sat3.JoinMethods.ensureTheOnlyTierWithVariableExistsAndGetTheTier; import static com.anjlab.sat3.JoinMethods.ensureTheOnlyTierWithVariablesExistsAndGetTheTier; import static com.anjlab.sat3.JoinMethods.startsWith; import cern.colt.list.ObjectArrayList;
{ return joinMethods; } public static boolean missingAll(ITabularFormula formula, int varName1, int varName2) { IPermutation permutation = formula.getPermutation(); return !permutation.contains(varName1) && !permutation.contains(varName2); } public static boolean startsWith(ITabularFormula formula, int varName) { return formula.getPermutation().get(0) == varName; } public static boolean startsWith(ITabularFormula formula, int varName1, int varName2) { IPermutation permutation = formula.getPermutation(); return permutation.get(0) == varName1 && permutation.get(1) == varName2; } public static boolean contains(ITabularFormula formula, int varName) { return formula.getPermutation().contains(varName); }
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static boolean canTranspose(ITabularFormula formula, ITier tier, int varName1, int varName2) // { // ITier otherTier = ensureTheOnlyTierWithVariableExistsAndGetTheTier(formula, varName1); // // if (otherTier != tier) // { // return false; // } // otherTier = ensureTheOnlyTierWithVariableExistsAndGetTheTier(formula, varName2); // if (otherTier != tier) // { // return false; // } // return true; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static boolean endsWith(ITabularFormula formula, int varName1, int varName2) // { // IPermutation permutation = formula.getPermutation(); // // int permutationSize = permutation.size(); // // return permutation.get(permutationSize - 2) == varName1 // && permutation.get(permutationSize - 1) == varName2; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static ITier ensureTheOnlyTierWithVariableExistsAndGetTheTier(ITabularFormula formula, int varName) // { // ObjectArrayList tiers = formula.findTiersFor(varName); // if (tiers == null) // { // return null; // } // if (tiers.size() == 1) // { // return (ITier) tiers.get(0); // } // return null; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static ITier ensureTheOnlyTierWithVariablesExistsAndGetTheTier(ITabularFormula formula, int varName1, int varName2) // { // ObjectArrayList tiers = formula.findTiersFor(varName1, varName2); // if (tiers == null) // { // return null; // } // if (tiers.size() == 1) // { // return (ITier) tiers.get(0); // } // return null; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static boolean startsWith(ITabularFormula formula, int varName) // { // return formula.getPermutation().get(0) == varName; // } // Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java import static com.anjlab.sat3.Join2BetweenTiers.canTranspose; import static com.anjlab.sat3.JoinMethods.endsWith; import static com.anjlab.sat3.JoinMethods.ensureTheOnlyTierWithVariableExistsAndGetTheTier; import static com.anjlab.sat3.JoinMethods.ensureTheOnlyTierWithVariablesExistsAndGetTheTier; import static com.anjlab.sat3.JoinMethods.startsWith; import cern.colt.list.ObjectArrayList; { return joinMethods; } public static boolean missingAll(ITabularFormula formula, int varName1, int varName2) { IPermutation permutation = formula.getPermutation(); return !permutation.contains(varName1) && !permutation.contains(varName2); } public static boolean startsWith(ITabularFormula formula, int varName) { return formula.getPermutation().get(0) == varName; } public static boolean startsWith(ITabularFormula formula, int varName1, int varName2) { IPermutation permutation = formula.getPermutation(); return permutation.get(0) == varName1 && permutation.get(1) == varName2; } public static boolean contains(ITabularFormula formula, int varName) { return formula.getPermutation().contains(varName); }
public static boolean endsWith(ITabularFormula formula, int varName1, int varName2)
anjlab/sat3
3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static boolean canTranspose(ITabularFormula formula, ITier tier, int varName1, int varName2) // { // ITier otherTier = ensureTheOnlyTierWithVariableExistsAndGetTheTier(formula, varName1); // // if (otherTier != tier) // { // return false; // } // otherTier = ensureTheOnlyTierWithVariableExistsAndGetTheTier(formula, varName2); // if (otherTier != tier) // { // return false; // } // return true; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static boolean endsWith(ITabularFormula formula, int varName1, int varName2) // { // IPermutation permutation = formula.getPermutation(); // // int permutationSize = permutation.size(); // // return permutation.get(permutationSize - 2) == varName1 // && permutation.get(permutationSize - 1) == varName2; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static ITier ensureTheOnlyTierWithVariableExistsAndGetTheTier(ITabularFormula formula, int varName) // { // ObjectArrayList tiers = formula.findTiersFor(varName); // if (tiers == null) // { // return null; // } // if (tiers.size() == 1) // { // return (ITier) tiers.get(0); // } // return null; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static ITier ensureTheOnlyTierWithVariablesExistsAndGetTheTier(ITabularFormula formula, int varName1, int varName2) // { // ObjectArrayList tiers = formula.findTiersFor(varName1, varName2); // if (tiers == null) // { // return null; // } // if (tiers.size() == 1) // { // return (ITier) tiers.get(0); // } // return null; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static boolean startsWith(ITabularFormula formula, int varName) // { // return formula.getPermutation().get(0) == varName; // }
import static com.anjlab.sat3.Join2BetweenTiers.canTranspose; import static com.anjlab.sat3.JoinMethods.endsWith; import static com.anjlab.sat3.JoinMethods.ensureTheOnlyTierWithVariableExistsAndGetTheTier; import static com.anjlab.sat3.JoinMethods.ensureTheOnlyTierWithVariablesExistsAndGetTheTier; import static com.anjlab.sat3.JoinMethods.startsWith; import cern.colt.list.ObjectArrayList;
} public static boolean startsWith(ITabularFormula formula, int varName1, int varName2) { IPermutation permutation = formula.getPermutation(); return permutation.get(0) == varName1 && permutation.get(1) == varName2; } public static boolean contains(ITabularFormula formula, int varName) { return formula.getPermutation().contains(varName); } public static boolean endsWith(ITabularFormula formula, int varName1, int varName2) { IPermutation permutation = formula.getPermutation(); int permutationSize = permutation.size(); return permutation.get(permutationSize - 2) == varName1 && permutation.get(permutationSize - 1) == varName2; } public static boolean endsWith(ITabularFormula formula, int varName) { return formula.getPermutation().get(formula.getPermutation().size() - 1) == varName; }
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static boolean canTranspose(ITabularFormula formula, ITier tier, int varName1, int varName2) // { // ITier otherTier = ensureTheOnlyTierWithVariableExistsAndGetTheTier(formula, varName1); // // if (otherTier != tier) // { // return false; // } // otherTier = ensureTheOnlyTierWithVariableExistsAndGetTheTier(formula, varName2); // if (otherTier != tier) // { // return false; // } // return true; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static boolean endsWith(ITabularFormula formula, int varName1, int varName2) // { // IPermutation permutation = formula.getPermutation(); // // int permutationSize = permutation.size(); // // return permutation.get(permutationSize - 2) == varName1 // && permutation.get(permutationSize - 1) == varName2; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static ITier ensureTheOnlyTierWithVariableExistsAndGetTheTier(ITabularFormula formula, int varName) // { // ObjectArrayList tiers = formula.findTiersFor(varName); // if (tiers == null) // { // return null; // } // if (tiers.size() == 1) // { // return (ITier) tiers.get(0); // } // return null; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static ITier ensureTheOnlyTierWithVariablesExistsAndGetTheTier(ITabularFormula formula, int varName1, int varName2) // { // ObjectArrayList tiers = formula.findTiersFor(varName1, varName2); // if (tiers == null) // { // return null; // } // if (tiers.size() == 1) // { // return (ITier) tiers.get(0); // } // return null; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static boolean startsWith(ITabularFormula formula, int varName) // { // return formula.getPermutation().get(0) == varName; // } // Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java import static com.anjlab.sat3.Join2BetweenTiers.canTranspose; import static com.anjlab.sat3.JoinMethods.endsWith; import static com.anjlab.sat3.JoinMethods.ensureTheOnlyTierWithVariableExistsAndGetTheTier; import static com.anjlab.sat3.JoinMethods.ensureTheOnlyTierWithVariablesExistsAndGetTheTier; import static com.anjlab.sat3.JoinMethods.startsWith; import cern.colt.list.ObjectArrayList; } public static boolean startsWith(ITabularFormula formula, int varName1, int varName2) { IPermutation permutation = formula.getPermutation(); return permutation.get(0) == varName1 && permutation.get(1) == varName2; } public static boolean contains(ITabularFormula formula, int varName) { return formula.getPermutation().contains(varName); } public static boolean endsWith(ITabularFormula formula, int varName1, int varName2) { IPermutation permutation = formula.getPermutation(); int permutationSize = permutation.size(); return permutation.get(permutationSize - 2) == varName1 && permutation.get(permutationSize - 1) == varName2; } public static boolean endsWith(ITabularFormula formula, int varName) { return formula.getPermutation().get(formula.getPermutation().size() - 1) == varName; }
public static ITier ensureTheOnlyTierWithVariableExistsAndGetTheTier(ITabularFormula formula, int varName)
anjlab/sat3
3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static boolean canTranspose(ITabularFormula formula, ITier tier, int varName1, int varName2) // { // ITier otherTier = ensureTheOnlyTierWithVariableExistsAndGetTheTier(formula, varName1); // // if (otherTier != tier) // { // return false; // } // otherTier = ensureTheOnlyTierWithVariableExistsAndGetTheTier(formula, varName2); // if (otherTier != tier) // { // return false; // } // return true; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static boolean endsWith(ITabularFormula formula, int varName1, int varName2) // { // IPermutation permutation = formula.getPermutation(); // // int permutationSize = permutation.size(); // // return permutation.get(permutationSize - 2) == varName1 // && permutation.get(permutationSize - 1) == varName2; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static ITier ensureTheOnlyTierWithVariableExistsAndGetTheTier(ITabularFormula formula, int varName) // { // ObjectArrayList tiers = formula.findTiersFor(varName); // if (tiers == null) // { // return null; // } // if (tiers.size() == 1) // { // return (ITier) tiers.get(0); // } // return null; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static ITier ensureTheOnlyTierWithVariablesExistsAndGetTheTier(ITabularFormula formula, int varName1, int varName2) // { // ObjectArrayList tiers = formula.findTiersFor(varName1, varName2); // if (tiers == null) // { // return null; // } // if (tiers.size() == 1) // { // return (ITier) tiers.get(0); // } // return null; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static boolean startsWith(ITabularFormula formula, int varName) // { // return formula.getPermutation().get(0) == varName; // }
import static com.anjlab.sat3.Join2BetweenTiers.canTranspose; import static com.anjlab.sat3.JoinMethods.endsWith; import static com.anjlab.sat3.JoinMethods.ensureTheOnlyTierWithVariableExistsAndGetTheTier; import static com.anjlab.sat3.JoinMethods.ensureTheOnlyTierWithVariablesExistsAndGetTheTier; import static com.anjlab.sat3.JoinMethods.startsWith; import cern.colt.list.ObjectArrayList;
public static boolean endsWith(ITabularFormula formula, int varName1, int varName2) { IPermutation permutation = formula.getPermutation(); int permutationSize = permutation.size(); return permutation.get(permutationSize - 2) == varName1 && permutation.get(permutationSize - 1) == varName2; } public static boolean endsWith(ITabularFormula formula, int varName) { return formula.getPermutation().get(formula.getPermutation().size() - 1) == varName; } public static ITier ensureTheOnlyTierWithVariableExistsAndGetTheTier(ITabularFormula formula, int varName) { ObjectArrayList tiers = formula.findTiersFor(varName); if (tiers == null) { return null; } if (tiers.size() == 1) { return (ITier) tiers.get(0); } return null; }
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static boolean canTranspose(ITabularFormula formula, ITier tier, int varName1, int varName2) // { // ITier otherTier = ensureTheOnlyTierWithVariableExistsAndGetTheTier(formula, varName1); // // if (otherTier != tier) // { // return false; // } // otherTier = ensureTheOnlyTierWithVariableExistsAndGetTheTier(formula, varName2); // if (otherTier != tier) // { // return false; // } // return true; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static boolean endsWith(ITabularFormula formula, int varName1, int varName2) // { // IPermutation permutation = formula.getPermutation(); // // int permutationSize = permutation.size(); // // return permutation.get(permutationSize - 2) == varName1 // && permutation.get(permutationSize - 1) == varName2; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static ITier ensureTheOnlyTierWithVariableExistsAndGetTheTier(ITabularFormula formula, int varName) // { // ObjectArrayList tiers = formula.findTiersFor(varName); // if (tiers == null) // { // return null; // } // if (tiers.size() == 1) // { // return (ITier) tiers.get(0); // } // return null; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static ITier ensureTheOnlyTierWithVariablesExistsAndGetTheTier(ITabularFormula formula, int varName1, int varName2) // { // ObjectArrayList tiers = formula.findTiersFor(varName1, varName2); // if (tiers == null) // { // return null; // } // if (tiers.size() == 1) // { // return (ITier) tiers.get(0); // } // return null; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static boolean startsWith(ITabularFormula formula, int varName) // { // return formula.getPermutation().get(0) == varName; // } // Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java import static com.anjlab.sat3.Join2BetweenTiers.canTranspose; import static com.anjlab.sat3.JoinMethods.endsWith; import static com.anjlab.sat3.JoinMethods.ensureTheOnlyTierWithVariableExistsAndGetTheTier; import static com.anjlab.sat3.JoinMethods.ensureTheOnlyTierWithVariablesExistsAndGetTheTier; import static com.anjlab.sat3.JoinMethods.startsWith; import cern.colt.list.ObjectArrayList; public static boolean endsWith(ITabularFormula formula, int varName1, int varName2) { IPermutation permutation = formula.getPermutation(); int permutationSize = permutation.size(); return permutation.get(permutationSize - 2) == varName1 && permutation.get(permutationSize - 1) == varName2; } public static boolean endsWith(ITabularFormula formula, int varName) { return formula.getPermutation().get(formula.getPermutation().size() - 1) == varName; } public static ITier ensureTheOnlyTierWithVariableExistsAndGetTheTier(ITabularFormula formula, int varName) { ObjectArrayList tiers = formula.findTiersFor(varName); if (tiers == null) { return null; } if (tiers.size() == 1) { return (ITier) tiers.get(0); } return null; }
public static ITier ensureTheOnlyTierWithVariablesExistsAndGetTheTier(ITabularFormula formula, int varName1, int varName2)
anjlab/sat3
3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static boolean canTranspose(ITabularFormula formula, ITier tier, int varName1, int varName2) // { // ITier otherTier = ensureTheOnlyTierWithVariableExistsAndGetTheTier(formula, varName1); // // if (otherTier != tier) // { // return false; // } // otherTier = ensureTheOnlyTierWithVariableExistsAndGetTheTier(formula, varName2); // if (otherTier != tier) // { // return false; // } // return true; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static boolean endsWith(ITabularFormula formula, int varName1, int varName2) // { // IPermutation permutation = formula.getPermutation(); // // int permutationSize = permutation.size(); // // return permutation.get(permutationSize - 2) == varName1 // && permutation.get(permutationSize - 1) == varName2; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static ITier ensureTheOnlyTierWithVariableExistsAndGetTheTier(ITabularFormula formula, int varName) // { // ObjectArrayList tiers = formula.findTiersFor(varName); // if (tiers == null) // { // return null; // } // if (tiers.size() == 1) // { // return (ITier) tiers.get(0); // } // return null; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static ITier ensureTheOnlyTierWithVariablesExistsAndGetTheTier(ITabularFormula formula, int varName1, int varName2) // { // ObjectArrayList tiers = formula.findTiersFor(varName1, varName2); // if (tiers == null) // { // return null; // } // if (tiers.size() == 1) // { // return (ITier) tiers.get(0); // } // return null; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static boolean startsWith(ITabularFormula formula, int varName) // { // return formula.getPermutation().get(0) == varName; // }
import static com.anjlab.sat3.Join2BetweenTiers.canTranspose; import static com.anjlab.sat3.JoinMethods.endsWith; import static com.anjlab.sat3.JoinMethods.ensureTheOnlyTierWithVariableExistsAndGetTheTier; import static com.anjlab.sat3.JoinMethods.ensureTheOnlyTierWithVariablesExistsAndGetTheTier; import static com.anjlab.sat3.JoinMethods.startsWith; import cern.colt.list.ObjectArrayList;
private boolean tryJoin2Left1Right(ITabularFormula formula, ITier tier, int left1, int left2, int right) { int left1Index = formula.getPermutation().indexOf(left1); int left2Index = formula.getPermutation().indexOf(left2); int rightIndex = formula.getPermutation().indexOf(right); if (left1Index > rightIndex || left2Index > rightIndex) { return false; } ITier leftTier = ensureTheOnlyTierWithVariablesExistsAndGetTheTier(formula, left1, left2); if (leftTier == null) { return false; } ITier rightTier = ensureTheOnlyTierWithVariableExistsAndGetTheTier(formula, right); if (rightTier == null) { return false; } if (leftTier == rightTier) { return false; } if (endsWith(leftTier, left1, left2)) { return transposeRightTierAndJoin(formula, tier, right, left2Index, rightIndex, rightTier, left1, left2); } else if (startsWith(leftTier, left1) && endsWith(leftTier, left2)
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static boolean canTranspose(ITabularFormula formula, ITier tier, int varName1, int varName2) // { // ITier otherTier = ensureTheOnlyTierWithVariableExistsAndGetTheTier(formula, varName1); // // if (otherTier != tier) // { // return false; // } // otherTier = ensureTheOnlyTierWithVariableExistsAndGetTheTier(formula, varName2); // if (otherTier != tier) // { // return false; // } // return true; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static boolean endsWith(ITabularFormula formula, int varName1, int varName2) // { // IPermutation permutation = formula.getPermutation(); // // int permutationSize = permutation.size(); // // return permutation.get(permutationSize - 2) == varName1 // && permutation.get(permutationSize - 1) == varName2; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static ITier ensureTheOnlyTierWithVariableExistsAndGetTheTier(ITabularFormula formula, int varName) // { // ObjectArrayList tiers = formula.findTiersFor(varName); // if (tiers == null) // { // return null; // } // if (tiers.size() == 1) // { // return (ITier) tiers.get(0); // } // return null; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static ITier ensureTheOnlyTierWithVariablesExistsAndGetTheTier(ITabularFormula formula, int varName1, int varName2) // { // ObjectArrayList tiers = formula.findTiersFor(varName1, varName2); // if (tiers == null) // { // return null; // } // if (tiers.size() == 1) // { // return (ITier) tiers.get(0); // } // return null; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java // public static boolean startsWith(ITabularFormula formula, int varName) // { // return formula.getPermutation().get(0) == varName; // } // Path: 3-sat-core/src/main/java/com/anjlab/sat3/JoinMethods.java import static com.anjlab.sat3.Join2BetweenTiers.canTranspose; import static com.anjlab.sat3.JoinMethods.endsWith; import static com.anjlab.sat3.JoinMethods.ensureTheOnlyTierWithVariableExistsAndGetTheTier; import static com.anjlab.sat3.JoinMethods.ensureTheOnlyTierWithVariablesExistsAndGetTheTier; import static com.anjlab.sat3.JoinMethods.startsWith; import cern.colt.list.ObjectArrayList; private boolean tryJoin2Left1Right(ITabularFormula formula, ITier tier, int left1, int left2, int right) { int left1Index = formula.getPermutation().indexOf(left1); int left2Index = formula.getPermutation().indexOf(left2); int rightIndex = formula.getPermutation().indexOf(right); if (left1Index > rightIndex || left2Index > rightIndex) { return false; } ITier leftTier = ensureTheOnlyTierWithVariablesExistsAndGetTheTier(formula, left1, left2); if (leftTier == null) { return false; } ITier rightTier = ensureTheOnlyTierWithVariableExistsAndGetTheTier(formula, right); if (rightTier == null) { return false; } if (leftTier == rightTier) { return false; } if (endsWith(leftTier, left1, left2)) { return transposeRightTierAndJoin(formula, tier, right, left2Index, rightIndex, rightTier, left1, left2); } else if (startsWith(leftTier, left1) && endsWith(leftTier, left2)
&& canTranspose(formula, leftTier, left1, leftTier.getBName()))
anjlab/sat3
3-sat-core/src/test/java/com/anjlab/sat3/TestLoadSave.java
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/Helper.java // public static ITabularFormula createRandomFormula(Random random, int varCount, int clausesCount) // { // int mMax = getMaxNumberOfUniqueTriplets(varCount); // // if (clausesCount > mMax) { // throw new IllegalArgumentException(MessageFormat // .format("3-SAT formula of {0} variables may have at most {1} valuable clauses, but requested to create formula with " + clausesCount + " clauses", // varCount, mMax)); // } // // ITabularFormula formula = new SimpleFormula(); // for (int i = 0; i < clausesCount && formula.getPermutation().size() < varCount; i++) // { // formula.add(createRandomTriplet(random, varCount)); // } // // return formula; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/Helper.java // public static ITabularFormula loadFromFile(String filename) throws IOException // { // String fileExt = filename.substring(filename.lastIndexOf('.'), filename.length()); // // IFormulaReader formulaReader; // if (".skt".equals(fileExt)) // { // formulaReader = new RomanovSKTFormulaReader(); // } // else // { // formulaReader = new GenericFormulaReader(); // } // // FileInputStream is = null; // try // { // is = new FileInputStream(new File(filename)); // // ITabularFormula formula = formulaReader.readFormula(is); // // // Clear SimpleFormula's tierHash3 after formula loaded // // ((SimpleFormula) formula).clearTierHash3(); // // return formula; // } // finally // { // if (is != null) // { // is.close(); // } // } // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/Helper.java // public static void prettyPrint(ITabularFormula formula) // { // printLine('-', 50); // // StringBuilder builder = buildPrettyOutput(formula); // builder.insert(0, '\n'); // // LOGGER.info(builder.toString()); // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/Helper.java // public static void saveToDIMACSFileFormat(ITabularFormula formula, String filename) throws IOException // { // BufferedWriter writer = null; // try { // writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(filename)), "ascii")); // // StringBuilder builder = new StringBuilder(); // builder.append("p cnf "); // builder.append(formula.getVarCount()); // builder.append(" "); // builder.append(formula.getClausesCount()); // builder.append('\n'); // ObjectArrayList tiers = formula.getTiers(); // for (int i = 0; i < tiers.size(); i++) // { // ITier tier = (ITier) tiers.get(i); // for (ITripletValue tripletValue : tier) // { // if (tripletValue.isNotA()) builder.append('-'); // builder.append(tier.getAName()); // builder.append(' '); // if (tripletValue.isNotB()) builder.append('-'); // builder.append(tier.getBName()); // builder.append(' '); // if (tripletValue.isNotC()) builder.append('-'); // builder.append(tier.getCName()); // builder.append(" 0\n"); // } // } // // writer.write(builder.toString()); // } // finally // { // if (writer != null) // { // writer.close(); // } // } // }
import java.io.IOException; import java.util.Random; import org.junit.BeforeClass; import org.junit.Test; import cern.colt.list.ObjectArrayList; import static com.anjlab.sat3.Helper.createRandomFormula; import static com.anjlab.sat3.Helper.loadFromFile; import static com.anjlab.sat3.Helper.prettyPrint; import static com.anjlab.sat3.Helper.saveToDIMACSFileFormat; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertNotNull; import static junit.framework.Assert.assertTrue;
/* * Copyright (c) 2010 AnjLab * * This file is part of * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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 * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * If not, see <http://www.gnu.org/licenses/>. */ package com.anjlab.sat3; public class TestLoadSave { @BeforeClass public static void setup() { Helper.UsePrettyPrint = true; Helper.EnableAssertions = true; System.out.println(TestLoadSave.class.getName()); } @Test public void testLoadFromDIMACS() throws IOException {
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/Helper.java // public static ITabularFormula createRandomFormula(Random random, int varCount, int clausesCount) // { // int mMax = getMaxNumberOfUniqueTriplets(varCount); // // if (clausesCount > mMax) { // throw new IllegalArgumentException(MessageFormat // .format("3-SAT formula of {0} variables may have at most {1} valuable clauses, but requested to create formula with " + clausesCount + " clauses", // varCount, mMax)); // } // // ITabularFormula formula = new SimpleFormula(); // for (int i = 0; i < clausesCount && formula.getPermutation().size() < varCount; i++) // { // formula.add(createRandomTriplet(random, varCount)); // } // // return formula; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/Helper.java // public static ITabularFormula loadFromFile(String filename) throws IOException // { // String fileExt = filename.substring(filename.lastIndexOf('.'), filename.length()); // // IFormulaReader formulaReader; // if (".skt".equals(fileExt)) // { // formulaReader = new RomanovSKTFormulaReader(); // } // else // { // formulaReader = new GenericFormulaReader(); // } // // FileInputStream is = null; // try // { // is = new FileInputStream(new File(filename)); // // ITabularFormula formula = formulaReader.readFormula(is); // // // Clear SimpleFormula's tierHash3 after formula loaded // // ((SimpleFormula) formula).clearTierHash3(); // // return formula; // } // finally // { // if (is != null) // { // is.close(); // } // } // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/Helper.java // public static void prettyPrint(ITabularFormula formula) // { // printLine('-', 50); // // StringBuilder builder = buildPrettyOutput(formula); // builder.insert(0, '\n'); // // LOGGER.info(builder.toString()); // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/Helper.java // public static void saveToDIMACSFileFormat(ITabularFormula formula, String filename) throws IOException // { // BufferedWriter writer = null; // try { // writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(filename)), "ascii")); // // StringBuilder builder = new StringBuilder(); // builder.append("p cnf "); // builder.append(formula.getVarCount()); // builder.append(" "); // builder.append(formula.getClausesCount()); // builder.append('\n'); // ObjectArrayList tiers = formula.getTiers(); // for (int i = 0; i < tiers.size(); i++) // { // ITier tier = (ITier) tiers.get(i); // for (ITripletValue tripletValue : tier) // { // if (tripletValue.isNotA()) builder.append('-'); // builder.append(tier.getAName()); // builder.append(' '); // if (tripletValue.isNotB()) builder.append('-'); // builder.append(tier.getBName()); // builder.append(' '); // if (tripletValue.isNotC()) builder.append('-'); // builder.append(tier.getCName()); // builder.append(" 0\n"); // } // } // // writer.write(builder.toString()); // } // finally // { // if (writer != null) // { // writer.close(); // } // } // } // Path: 3-sat-core/src/test/java/com/anjlab/sat3/TestLoadSave.java import java.io.IOException; import java.util.Random; import org.junit.BeforeClass; import org.junit.Test; import cern.colt.list.ObjectArrayList; import static com.anjlab.sat3.Helper.createRandomFormula; import static com.anjlab.sat3.Helper.loadFromFile; import static com.anjlab.sat3.Helper.prettyPrint; import static com.anjlab.sat3.Helper.saveToDIMACSFileFormat; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertNotNull; import static junit.framework.Assert.assertTrue; /* * Copyright (c) 2010 AnjLab * * This file is part of * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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 * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * If not, see <http://www.gnu.org/licenses/>. */ package com.anjlab.sat3; public class TestLoadSave { @BeforeClass public static void setup() { Helper.UsePrettyPrint = true; Helper.EnableAssertions = true; System.out.println(TestLoadSave.class.getName()); } @Test public void testLoadFromDIMACS() throws IOException {
ITabularFormula formula = loadFromFile("target/test-classes/article-example.cnf");
anjlab/sat3
3-sat-core/src/test/java/com/anjlab/sat3/TestLoadSave.java
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/Helper.java // public static ITabularFormula createRandomFormula(Random random, int varCount, int clausesCount) // { // int mMax = getMaxNumberOfUniqueTriplets(varCount); // // if (clausesCount > mMax) { // throw new IllegalArgumentException(MessageFormat // .format("3-SAT formula of {0} variables may have at most {1} valuable clauses, but requested to create formula with " + clausesCount + " clauses", // varCount, mMax)); // } // // ITabularFormula formula = new SimpleFormula(); // for (int i = 0; i < clausesCount && formula.getPermutation().size() < varCount; i++) // { // formula.add(createRandomTriplet(random, varCount)); // } // // return formula; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/Helper.java // public static ITabularFormula loadFromFile(String filename) throws IOException // { // String fileExt = filename.substring(filename.lastIndexOf('.'), filename.length()); // // IFormulaReader formulaReader; // if (".skt".equals(fileExt)) // { // formulaReader = new RomanovSKTFormulaReader(); // } // else // { // formulaReader = new GenericFormulaReader(); // } // // FileInputStream is = null; // try // { // is = new FileInputStream(new File(filename)); // // ITabularFormula formula = formulaReader.readFormula(is); // // // Clear SimpleFormula's tierHash3 after formula loaded // // ((SimpleFormula) formula).clearTierHash3(); // // return formula; // } // finally // { // if (is != null) // { // is.close(); // } // } // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/Helper.java // public static void prettyPrint(ITabularFormula formula) // { // printLine('-', 50); // // StringBuilder builder = buildPrettyOutput(formula); // builder.insert(0, '\n'); // // LOGGER.info(builder.toString()); // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/Helper.java // public static void saveToDIMACSFileFormat(ITabularFormula formula, String filename) throws IOException // { // BufferedWriter writer = null; // try { // writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(filename)), "ascii")); // // StringBuilder builder = new StringBuilder(); // builder.append("p cnf "); // builder.append(formula.getVarCount()); // builder.append(" "); // builder.append(formula.getClausesCount()); // builder.append('\n'); // ObjectArrayList tiers = formula.getTiers(); // for (int i = 0; i < tiers.size(); i++) // { // ITier tier = (ITier) tiers.get(i); // for (ITripletValue tripletValue : tier) // { // if (tripletValue.isNotA()) builder.append('-'); // builder.append(tier.getAName()); // builder.append(' '); // if (tripletValue.isNotB()) builder.append('-'); // builder.append(tier.getBName()); // builder.append(' '); // if (tripletValue.isNotC()) builder.append('-'); // builder.append(tier.getCName()); // builder.append(" 0\n"); // } // } // // writer.write(builder.toString()); // } // finally // { // if (writer != null) // { // writer.close(); // } // } // }
import java.io.IOException; import java.util.Random; import org.junit.BeforeClass; import org.junit.Test; import cern.colt.list.ObjectArrayList; import static com.anjlab.sat3.Helper.createRandomFormula; import static com.anjlab.sat3.Helper.loadFromFile; import static com.anjlab.sat3.Helper.prettyPrint; import static com.anjlab.sat3.Helper.saveToDIMACSFileFormat; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertNotNull; import static junit.framework.Assert.assertTrue;
/* * Copyright (c) 2010 AnjLab * * This file is part of * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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 * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * If not, see <http://www.gnu.org/licenses/>. */ package com.anjlab.sat3; public class TestLoadSave { @BeforeClass public static void setup() { Helper.UsePrettyPrint = true; Helper.EnableAssertions = true; System.out.println(TestLoadSave.class.getName()); } @Test public void testLoadFromDIMACS() throws IOException { ITabularFormula formula = loadFromFile("target/test-classes/article-example.cnf");
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/Helper.java // public static ITabularFormula createRandomFormula(Random random, int varCount, int clausesCount) // { // int mMax = getMaxNumberOfUniqueTriplets(varCount); // // if (clausesCount > mMax) { // throw new IllegalArgumentException(MessageFormat // .format("3-SAT formula of {0} variables may have at most {1} valuable clauses, but requested to create formula with " + clausesCount + " clauses", // varCount, mMax)); // } // // ITabularFormula formula = new SimpleFormula(); // for (int i = 0; i < clausesCount && formula.getPermutation().size() < varCount; i++) // { // formula.add(createRandomTriplet(random, varCount)); // } // // return formula; // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/Helper.java // public static ITabularFormula loadFromFile(String filename) throws IOException // { // String fileExt = filename.substring(filename.lastIndexOf('.'), filename.length()); // // IFormulaReader formulaReader; // if (".skt".equals(fileExt)) // { // formulaReader = new RomanovSKTFormulaReader(); // } // else // { // formulaReader = new GenericFormulaReader(); // } // // FileInputStream is = null; // try // { // is = new FileInputStream(new File(filename)); // // ITabularFormula formula = formulaReader.readFormula(is); // // // Clear SimpleFormula's tierHash3 after formula loaded // // ((SimpleFormula) formula).clearTierHash3(); // // return formula; // } // finally // { // if (is != null) // { // is.close(); // } // } // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/Helper.java // public static void prettyPrint(ITabularFormula formula) // { // printLine('-', 50); // // StringBuilder builder = buildPrettyOutput(formula); // builder.insert(0, '\n'); // // LOGGER.info(builder.toString()); // } // // Path: 3-sat-core/src/main/java/com/anjlab/sat3/Helper.java // public static void saveToDIMACSFileFormat(ITabularFormula formula, String filename) throws IOException // { // BufferedWriter writer = null; // try { // writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(filename)), "ascii")); // // StringBuilder builder = new StringBuilder(); // builder.append("p cnf "); // builder.append(formula.getVarCount()); // builder.append(" "); // builder.append(formula.getClausesCount()); // builder.append('\n'); // ObjectArrayList tiers = formula.getTiers(); // for (int i = 0; i < tiers.size(); i++) // { // ITier tier = (ITier) tiers.get(i); // for (ITripletValue tripletValue : tier) // { // if (tripletValue.isNotA()) builder.append('-'); // builder.append(tier.getAName()); // builder.append(' '); // if (tripletValue.isNotB()) builder.append('-'); // builder.append(tier.getBName()); // builder.append(' '); // if (tripletValue.isNotC()) builder.append('-'); // builder.append(tier.getCName()); // builder.append(" 0\n"); // } // } // // writer.write(builder.toString()); // } // finally // { // if (writer != null) // { // writer.close(); // } // } // } // Path: 3-sat-core/src/test/java/com/anjlab/sat3/TestLoadSave.java import java.io.IOException; import java.util.Random; import org.junit.BeforeClass; import org.junit.Test; import cern.colt.list.ObjectArrayList; import static com.anjlab.sat3.Helper.createRandomFormula; import static com.anjlab.sat3.Helper.loadFromFile; import static com.anjlab.sat3.Helper.prettyPrint; import static com.anjlab.sat3.Helper.saveToDIMACSFileFormat; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertNotNull; import static junit.framework.Assert.assertTrue; /* * Copyright (c) 2010 AnjLab * * This file is part of * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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 * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * If not, see <http://www.gnu.org/licenses/>. */ package com.anjlab.sat3; public class TestLoadSave { @BeforeClass public static void setup() { Helper.UsePrettyPrint = true; Helper.EnableAssertions = true; System.out.println(TestLoadSave.class.getName()); } @Test public void testLoadFromDIMACS() throws IOException { ITabularFormula formula = loadFromFile("target/test-classes/article-example.cnf");
prettyPrint(formula);
anjlab/sat3
3-sat-core/src/main/java/com/anjlab/sat3/Program.java
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/Helper.java // public static void printFormulas(ObjectArrayList formulas) // { // for (int i = 0; i < formulas.size(); i++) // { // Helper.prettyPrint((ITabularFormula) formulas.get(i)); // } // }
import java.io.OutputStream; import java.util.Properties; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.CommandLineParser; import org.apache.commons.cli.HelpFormatter; import org.apache.commons.cli.OptionBuilder; import org.apache.commons.cli.Options; import org.apache.commons.cli.PosixParser; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import cern.colt.list.ObjectArrayList; import static com.anjlab.sat3.Helper.printFormulas; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException;
{ String resultsFilename = commandLine.getOptionValue(EVALUATE_OPTION); boolean satisfiable = evaluateFormula(stopWatch, formula, resultsFilename); if (satisfiable) { System.out.println("Formula evaluated as SAT"); } else { System.out.println("Formula evaluated as UNSAT"); } // Only evaluate formula value return; } // Find if formula is SAT // Clone initial formula to verify formula satisfiability later ITabularFormula formulaClone = null; if (Helper.EnableAssertions) { stopWatch.start("Clone initial formula"); formulaClone = formula.clone(); stopWatch.stop(); stopWatch.printElapsed(); } stopWatch.start("Create CTF"); ObjectArrayList ct = Helper.createCTF(formula); timeElapsed = stopWatch.stop();
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/Helper.java // public static void printFormulas(ObjectArrayList formulas) // { // for (int i = 0; i < formulas.size(); i++) // { // Helper.prettyPrint((ITabularFormula) formulas.get(i)); // } // } // Path: 3-sat-core/src/main/java/com/anjlab/sat3/Program.java import java.io.OutputStream; import java.util.Properties; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.CommandLineParser; import org.apache.commons.cli.HelpFormatter; import org.apache.commons.cli.OptionBuilder; import org.apache.commons.cli.Options; import org.apache.commons.cli.PosixParser; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import cern.colt.list.ObjectArrayList; import static com.anjlab.sat3.Helper.printFormulas; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; { String resultsFilename = commandLine.getOptionValue(EVALUATE_OPTION); boolean satisfiable = evaluateFormula(stopWatch, formula, resultsFilename); if (satisfiable) { System.out.println("Formula evaluated as SAT"); } else { System.out.println("Formula evaluated as UNSAT"); } // Only evaluate formula value return; } // Find if formula is SAT // Clone initial formula to verify formula satisfiability later ITabularFormula formulaClone = null; if (Helper.EnableAssertions) { stopWatch.start("Clone initial formula"); formulaClone = formula.clone(); stopWatch.stop(); stopWatch.printElapsed(); } stopWatch.start("Create CTF"); ObjectArrayList ct = Helper.createCTF(formula); timeElapsed = stopWatch.stop();
printFormulas(ct);
anjlab/sat3
3-sat-core/src/test/java/com/anjlab/sat3/TestSimpleFormula.java
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _111_instance = new _111();
import static com.anjlab.sat3.SimpleTripletValueFactory._111_instance; import static org.junit.Assert.assertTrue; import org.junit.Test; import cern.colt.list.ObjectArrayList;
/* * Copyright (c) 2010 AnjLab * * This file is part of * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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 * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * If not, see <http://www.gnu.org/licenses/>. */ package com.anjlab.sat3; public class TestSimpleFormula { @Test public void testEvaluate() { ITabularFormula formula = Helper.createFormula(1, 2, 3); ObjectArrayList route = new ObjectArrayList(); // Route contains inverse values
// Path: 3-sat-core/src/main/java/com/anjlab/sat3/SimpleTripletValueFactory.java // public static final ITripletValue _111_instance = new _111(); // Path: 3-sat-core/src/test/java/com/anjlab/sat3/TestSimpleFormula.java import static com.anjlab.sat3.SimpleTripletValueFactory._111_instance; import static org.junit.Assert.assertTrue; import org.junit.Test; import cern.colt.list.ObjectArrayList; /* * Copyright (c) 2010 AnjLab * * This file is part of * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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. * * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem * 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 * Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem. * If not, see <http://www.gnu.org/licenses/>. */ package com.anjlab.sat3; public class TestSimpleFormula { @Test public void testEvaluate() { ITabularFormula formula = Helper.createFormula(1, 2, 3); ObjectArrayList route = new ObjectArrayList(); // Route contains inverse values
route.add(new SimpleVertex(new SimpleTripletPermutation(1, 2, 3), 0, _111_instance, null));
marcelothebuilder/webpedidos
src/main/java/com/github/marcelothebuilder/webpedidos/controller/RelatorioPedidosEmitidosBean.java
// Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/EmissorRelatorio.java // public interface EmissorRelatorio { // // void setConnection(Connection connection); // // void emitir() throws IOException, JRException; // // boolean isRelatorioGerado(); // // } // // Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/ExecutorRelatorio.java // public interface ExecutorRelatorio { // // void emite(); // // void setEmissor(EmissorRelatorio emissor); // // } // // Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/Relatorio.java // public interface Relatorio { // // Map<String, Object> getParametros(); // // RelatorioFile getArquivo(); // } // // Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/impl/EmissorRelatorioServlet.java // public final class EmissorRelatorioServlet implements EmissorRelatorio { // private Relatorio relatorio; // private Connection connection; // private HttpServletResponse servletResponse; // private boolean relatorioGerado = false; // // public EmissorRelatorioServlet(Relatorio relatorio, HttpServletResponse servletResponse) { // this.relatorio = relatorio; // this.servletResponse = servletResponse; // } // // public EmissorRelatorioServlet(Relatorio relatorio, HttpServletResponse output, Connection connection) { // this(relatorio, output); // this.connection = connection; // } // // /* (non-Javadoc) // * @see com.github.marcelothebuilder.webpedidos.util.report.impl.EmissorRelatorio#setConnection(java.sql.Connection) // */ // @Override // public void setConnection(Connection connection) { // this.connection = connection; // } // // /* (non-Javadoc) // * @see com.github.marcelothebuilder.webpedidos.util.report.impl.EmissorRelatorio#emitir() // */ // @Override // public void emitir() throws JRException { // try (InputStream relatorioArquivoStream = this.getClass().getResourceAsStream(relatorio.getArquivo().getCaminho())) { // JasperPrint print = JasperFillManager.fillReport(relatorioArquivoStream, relatorio.getParametros(), connection); // this.relatorioGerado = print.getPages().size() > 0; // // if(this.isRelatorioGerado()) { // String attachment = String.format("attachment; filename=\"%s.pdf\"", relatorio.getArquivo().getNome()); // servletResponse.setHeader("Content-Disposition", attachment); // JasperExportManager.exportReportToPdfStream(print, servletResponse.getOutputStream()); // } // } catch (IOException e) { // throw new RelatorioNaoExisteException(relatorio, e); // } // } // // /* (non-Javadoc) // * @see com.github.marcelothebuilder.webpedidos.util.report.impl.EmissorRelatorio#isRelatorioGerado() // */ // @Override // public boolean isRelatorioGerado() { // return this.relatorioGerado; // } // // } // // Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/impl/RelatorioPedidosEmitidos.java // public final class RelatorioPedidosEmitidos extends RelatorioPedidos { // public RelatorioPedidosEmitidos(Date dataInicio, Date dataFim) { // super(dataInicio, dataFim, RelatorioUtils.localizaRelatorio("relatorio_pedidos_emitidos")); // } // }
import java.io.IOException; import java.io.Serializable; import java.util.Calendar; import java.util.Date; import javax.enterprise.context.RequestScoped; import javax.faces.application.FacesMessage; import javax.faces.context.FacesContext; import javax.inject.Inject; import javax.inject.Named; import javax.servlet.http.HttpServletResponse; import javax.validation.constraints.NotNull; import javax.validation.constraints.Past; import org.joda.time.Days; import org.joda.time.LocalDate; import com.github.marcelothebuilder.webpedidos.util.report.EmissorRelatorio; import com.github.marcelothebuilder.webpedidos.util.report.ExecutorRelatorio; import com.github.marcelothebuilder.webpedidos.util.report.Relatorio; import com.github.marcelothebuilder.webpedidos.util.report.impl.EmissorRelatorioServlet; import com.github.marcelothebuilder.webpedidos.util.report.impl.RelatorioPedidosEmitidos;
/** * */ package com.github.marcelothebuilder.webpedidos.controller; /** * Este bean é responsável pela emissão de relatórios dos pedidos emitidos. * Fornece limitações de data e exporta o relatório para o navegador * diretamente, validando erros de entrada do usuário. * * @author Marcelo Paixao Resende * */ @Named @RequestScoped public class RelatorioPedidosEmitidosBean implements Serializable { private static final long serialVersionUID = 1L; private @Inject HttpServletResponse response; private @Inject FacesContext fContext;
// Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/EmissorRelatorio.java // public interface EmissorRelatorio { // // void setConnection(Connection connection); // // void emitir() throws IOException, JRException; // // boolean isRelatorioGerado(); // // } // // Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/ExecutorRelatorio.java // public interface ExecutorRelatorio { // // void emite(); // // void setEmissor(EmissorRelatorio emissor); // // } // // Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/Relatorio.java // public interface Relatorio { // // Map<String, Object> getParametros(); // // RelatorioFile getArquivo(); // } // // Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/impl/EmissorRelatorioServlet.java // public final class EmissorRelatorioServlet implements EmissorRelatorio { // private Relatorio relatorio; // private Connection connection; // private HttpServletResponse servletResponse; // private boolean relatorioGerado = false; // // public EmissorRelatorioServlet(Relatorio relatorio, HttpServletResponse servletResponse) { // this.relatorio = relatorio; // this.servletResponse = servletResponse; // } // // public EmissorRelatorioServlet(Relatorio relatorio, HttpServletResponse output, Connection connection) { // this(relatorio, output); // this.connection = connection; // } // // /* (non-Javadoc) // * @see com.github.marcelothebuilder.webpedidos.util.report.impl.EmissorRelatorio#setConnection(java.sql.Connection) // */ // @Override // public void setConnection(Connection connection) { // this.connection = connection; // } // // /* (non-Javadoc) // * @see com.github.marcelothebuilder.webpedidos.util.report.impl.EmissorRelatorio#emitir() // */ // @Override // public void emitir() throws JRException { // try (InputStream relatorioArquivoStream = this.getClass().getResourceAsStream(relatorio.getArquivo().getCaminho())) { // JasperPrint print = JasperFillManager.fillReport(relatorioArquivoStream, relatorio.getParametros(), connection); // this.relatorioGerado = print.getPages().size() > 0; // // if(this.isRelatorioGerado()) { // String attachment = String.format("attachment; filename=\"%s.pdf\"", relatorio.getArquivo().getNome()); // servletResponse.setHeader("Content-Disposition", attachment); // JasperExportManager.exportReportToPdfStream(print, servletResponse.getOutputStream()); // } // } catch (IOException e) { // throw new RelatorioNaoExisteException(relatorio, e); // } // } // // /* (non-Javadoc) // * @see com.github.marcelothebuilder.webpedidos.util.report.impl.EmissorRelatorio#isRelatorioGerado() // */ // @Override // public boolean isRelatorioGerado() { // return this.relatorioGerado; // } // // } // // Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/impl/RelatorioPedidosEmitidos.java // public final class RelatorioPedidosEmitidos extends RelatorioPedidos { // public RelatorioPedidosEmitidos(Date dataInicio, Date dataFim) { // super(dataInicio, dataFim, RelatorioUtils.localizaRelatorio("relatorio_pedidos_emitidos")); // } // } // Path: src/main/java/com/github/marcelothebuilder/webpedidos/controller/RelatorioPedidosEmitidosBean.java import java.io.IOException; import java.io.Serializable; import java.util.Calendar; import java.util.Date; import javax.enterprise.context.RequestScoped; import javax.faces.application.FacesMessage; import javax.faces.context.FacesContext; import javax.inject.Inject; import javax.inject.Named; import javax.servlet.http.HttpServletResponse; import javax.validation.constraints.NotNull; import javax.validation.constraints.Past; import org.joda.time.Days; import org.joda.time.LocalDate; import com.github.marcelothebuilder.webpedidos.util.report.EmissorRelatorio; import com.github.marcelothebuilder.webpedidos.util.report.ExecutorRelatorio; import com.github.marcelothebuilder.webpedidos.util.report.Relatorio; import com.github.marcelothebuilder.webpedidos.util.report.impl.EmissorRelatorioServlet; import com.github.marcelothebuilder.webpedidos.util.report.impl.RelatorioPedidosEmitidos; /** * */ package com.github.marcelothebuilder.webpedidos.controller; /** * Este bean é responsável pela emissão de relatórios dos pedidos emitidos. * Fornece limitações de data e exporta o relatório para o navegador * diretamente, validando erros de entrada do usuário. * * @author Marcelo Paixao Resende * */ @Named @RequestScoped public class RelatorioPedidosEmitidosBean implements Serializable { private static final long serialVersionUID = 1L; private @Inject HttpServletResponse response; private @Inject FacesContext fContext;
private @Inject ExecutorRelatorio executor;
marcelothebuilder/webpedidos
src/main/java/com/github/marcelothebuilder/webpedidos/controller/RelatorioPedidosEmitidosBean.java
// Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/EmissorRelatorio.java // public interface EmissorRelatorio { // // void setConnection(Connection connection); // // void emitir() throws IOException, JRException; // // boolean isRelatorioGerado(); // // } // // Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/ExecutorRelatorio.java // public interface ExecutorRelatorio { // // void emite(); // // void setEmissor(EmissorRelatorio emissor); // // } // // Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/Relatorio.java // public interface Relatorio { // // Map<String, Object> getParametros(); // // RelatorioFile getArquivo(); // } // // Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/impl/EmissorRelatorioServlet.java // public final class EmissorRelatorioServlet implements EmissorRelatorio { // private Relatorio relatorio; // private Connection connection; // private HttpServletResponse servletResponse; // private boolean relatorioGerado = false; // // public EmissorRelatorioServlet(Relatorio relatorio, HttpServletResponse servletResponse) { // this.relatorio = relatorio; // this.servletResponse = servletResponse; // } // // public EmissorRelatorioServlet(Relatorio relatorio, HttpServletResponse output, Connection connection) { // this(relatorio, output); // this.connection = connection; // } // // /* (non-Javadoc) // * @see com.github.marcelothebuilder.webpedidos.util.report.impl.EmissorRelatorio#setConnection(java.sql.Connection) // */ // @Override // public void setConnection(Connection connection) { // this.connection = connection; // } // // /* (non-Javadoc) // * @see com.github.marcelothebuilder.webpedidos.util.report.impl.EmissorRelatorio#emitir() // */ // @Override // public void emitir() throws JRException { // try (InputStream relatorioArquivoStream = this.getClass().getResourceAsStream(relatorio.getArquivo().getCaminho())) { // JasperPrint print = JasperFillManager.fillReport(relatorioArquivoStream, relatorio.getParametros(), connection); // this.relatorioGerado = print.getPages().size() > 0; // // if(this.isRelatorioGerado()) { // String attachment = String.format("attachment; filename=\"%s.pdf\"", relatorio.getArquivo().getNome()); // servletResponse.setHeader("Content-Disposition", attachment); // JasperExportManager.exportReportToPdfStream(print, servletResponse.getOutputStream()); // } // } catch (IOException e) { // throw new RelatorioNaoExisteException(relatorio, e); // } // } // // /* (non-Javadoc) // * @see com.github.marcelothebuilder.webpedidos.util.report.impl.EmissorRelatorio#isRelatorioGerado() // */ // @Override // public boolean isRelatorioGerado() { // return this.relatorioGerado; // } // // } // // Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/impl/RelatorioPedidosEmitidos.java // public final class RelatorioPedidosEmitidos extends RelatorioPedidos { // public RelatorioPedidosEmitidos(Date dataInicio, Date dataFim) { // super(dataInicio, dataFim, RelatorioUtils.localizaRelatorio("relatorio_pedidos_emitidos")); // } // }
import java.io.IOException; import java.io.Serializable; import java.util.Calendar; import java.util.Date; import javax.enterprise.context.RequestScoped; import javax.faces.application.FacesMessage; import javax.faces.context.FacesContext; import javax.inject.Inject; import javax.inject.Named; import javax.servlet.http.HttpServletResponse; import javax.validation.constraints.NotNull; import javax.validation.constraints.Past; import org.joda.time.Days; import org.joda.time.LocalDate; import com.github.marcelothebuilder.webpedidos.util.report.EmissorRelatorio; import com.github.marcelothebuilder.webpedidos.util.report.ExecutorRelatorio; import com.github.marcelothebuilder.webpedidos.util.report.Relatorio; import com.github.marcelothebuilder.webpedidos.util.report.impl.EmissorRelatorioServlet; import com.github.marcelothebuilder.webpedidos.util.report.impl.RelatorioPedidosEmitidos;
Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(1L); return cal.getTime(); } /** * Valida as informações informadas pelo usuário, e caso estejam corretas, * emite a stream do relatório gerado para o client, caso contrário, * fornecem uma mensagem de erro. * * @throws IOException */ public void emitir() { if (this.getDataInicio().after(getDataFim())) { String message = "A data de início deve ser maior que a data fim."; FacesMessage fMessage = new FacesMessage(FacesMessage.SEVERITY_WARN, message, message); fContext.addMessage(null, fMessage); return; } int diasBetween = getIntervaloDias(this.getDataInicio(), this.getDataFim()); if (diasBetween > 180) { String message = "Não é possível emitir um relatório para mais que 180 dias."; FacesMessage fMessage = new FacesMessage(FacesMessage.SEVERITY_WARN, message, message); fContext.addMessage(null, fMessage); return; }
// Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/EmissorRelatorio.java // public interface EmissorRelatorio { // // void setConnection(Connection connection); // // void emitir() throws IOException, JRException; // // boolean isRelatorioGerado(); // // } // // Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/ExecutorRelatorio.java // public interface ExecutorRelatorio { // // void emite(); // // void setEmissor(EmissorRelatorio emissor); // // } // // Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/Relatorio.java // public interface Relatorio { // // Map<String, Object> getParametros(); // // RelatorioFile getArquivo(); // } // // Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/impl/EmissorRelatorioServlet.java // public final class EmissorRelatorioServlet implements EmissorRelatorio { // private Relatorio relatorio; // private Connection connection; // private HttpServletResponse servletResponse; // private boolean relatorioGerado = false; // // public EmissorRelatorioServlet(Relatorio relatorio, HttpServletResponse servletResponse) { // this.relatorio = relatorio; // this.servletResponse = servletResponse; // } // // public EmissorRelatorioServlet(Relatorio relatorio, HttpServletResponse output, Connection connection) { // this(relatorio, output); // this.connection = connection; // } // // /* (non-Javadoc) // * @see com.github.marcelothebuilder.webpedidos.util.report.impl.EmissorRelatorio#setConnection(java.sql.Connection) // */ // @Override // public void setConnection(Connection connection) { // this.connection = connection; // } // // /* (non-Javadoc) // * @see com.github.marcelothebuilder.webpedidos.util.report.impl.EmissorRelatorio#emitir() // */ // @Override // public void emitir() throws JRException { // try (InputStream relatorioArquivoStream = this.getClass().getResourceAsStream(relatorio.getArquivo().getCaminho())) { // JasperPrint print = JasperFillManager.fillReport(relatorioArquivoStream, relatorio.getParametros(), connection); // this.relatorioGerado = print.getPages().size() > 0; // // if(this.isRelatorioGerado()) { // String attachment = String.format("attachment; filename=\"%s.pdf\"", relatorio.getArquivo().getNome()); // servletResponse.setHeader("Content-Disposition", attachment); // JasperExportManager.exportReportToPdfStream(print, servletResponse.getOutputStream()); // } // } catch (IOException e) { // throw new RelatorioNaoExisteException(relatorio, e); // } // } // // /* (non-Javadoc) // * @see com.github.marcelothebuilder.webpedidos.util.report.impl.EmissorRelatorio#isRelatorioGerado() // */ // @Override // public boolean isRelatorioGerado() { // return this.relatorioGerado; // } // // } // // Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/impl/RelatorioPedidosEmitidos.java // public final class RelatorioPedidosEmitidos extends RelatorioPedidos { // public RelatorioPedidosEmitidos(Date dataInicio, Date dataFim) { // super(dataInicio, dataFim, RelatorioUtils.localizaRelatorio("relatorio_pedidos_emitidos")); // } // } // Path: src/main/java/com/github/marcelothebuilder/webpedidos/controller/RelatorioPedidosEmitidosBean.java import java.io.IOException; import java.io.Serializable; import java.util.Calendar; import java.util.Date; import javax.enterprise.context.RequestScoped; import javax.faces.application.FacesMessage; import javax.faces.context.FacesContext; import javax.inject.Inject; import javax.inject.Named; import javax.servlet.http.HttpServletResponse; import javax.validation.constraints.NotNull; import javax.validation.constraints.Past; import org.joda.time.Days; import org.joda.time.LocalDate; import com.github.marcelothebuilder.webpedidos.util.report.EmissorRelatorio; import com.github.marcelothebuilder.webpedidos.util.report.ExecutorRelatorio; import com.github.marcelothebuilder.webpedidos.util.report.Relatorio; import com.github.marcelothebuilder.webpedidos.util.report.impl.EmissorRelatorioServlet; import com.github.marcelothebuilder.webpedidos.util.report.impl.RelatorioPedidosEmitidos; Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(1L); return cal.getTime(); } /** * Valida as informações informadas pelo usuário, e caso estejam corretas, * emite a stream do relatório gerado para o client, caso contrário, * fornecem uma mensagem de erro. * * @throws IOException */ public void emitir() { if (this.getDataInicio().after(getDataFim())) { String message = "A data de início deve ser maior que a data fim."; FacesMessage fMessage = new FacesMessage(FacesMessage.SEVERITY_WARN, message, message); fContext.addMessage(null, fMessage); return; } int diasBetween = getIntervaloDias(this.getDataInicio(), this.getDataFim()); if (diasBetween > 180) { String message = "Não é possível emitir um relatório para mais que 180 dias."; FacesMessage fMessage = new FacesMessage(FacesMessage.SEVERITY_WARN, message, message); fContext.addMessage(null, fMessage); return; }
Relatorio relatorioPedidos = new RelatorioPedidosEmitidos(getDataInicio(), getDataFim());
marcelothebuilder/webpedidos
src/main/java/com/github/marcelothebuilder/webpedidos/controller/RelatorioPedidosEmitidosBean.java
// Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/EmissorRelatorio.java // public interface EmissorRelatorio { // // void setConnection(Connection connection); // // void emitir() throws IOException, JRException; // // boolean isRelatorioGerado(); // // } // // Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/ExecutorRelatorio.java // public interface ExecutorRelatorio { // // void emite(); // // void setEmissor(EmissorRelatorio emissor); // // } // // Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/Relatorio.java // public interface Relatorio { // // Map<String, Object> getParametros(); // // RelatorioFile getArquivo(); // } // // Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/impl/EmissorRelatorioServlet.java // public final class EmissorRelatorioServlet implements EmissorRelatorio { // private Relatorio relatorio; // private Connection connection; // private HttpServletResponse servletResponse; // private boolean relatorioGerado = false; // // public EmissorRelatorioServlet(Relatorio relatorio, HttpServletResponse servletResponse) { // this.relatorio = relatorio; // this.servletResponse = servletResponse; // } // // public EmissorRelatorioServlet(Relatorio relatorio, HttpServletResponse output, Connection connection) { // this(relatorio, output); // this.connection = connection; // } // // /* (non-Javadoc) // * @see com.github.marcelothebuilder.webpedidos.util.report.impl.EmissorRelatorio#setConnection(java.sql.Connection) // */ // @Override // public void setConnection(Connection connection) { // this.connection = connection; // } // // /* (non-Javadoc) // * @see com.github.marcelothebuilder.webpedidos.util.report.impl.EmissorRelatorio#emitir() // */ // @Override // public void emitir() throws JRException { // try (InputStream relatorioArquivoStream = this.getClass().getResourceAsStream(relatorio.getArquivo().getCaminho())) { // JasperPrint print = JasperFillManager.fillReport(relatorioArquivoStream, relatorio.getParametros(), connection); // this.relatorioGerado = print.getPages().size() > 0; // // if(this.isRelatorioGerado()) { // String attachment = String.format("attachment; filename=\"%s.pdf\"", relatorio.getArquivo().getNome()); // servletResponse.setHeader("Content-Disposition", attachment); // JasperExportManager.exportReportToPdfStream(print, servletResponse.getOutputStream()); // } // } catch (IOException e) { // throw new RelatorioNaoExisteException(relatorio, e); // } // } // // /* (non-Javadoc) // * @see com.github.marcelothebuilder.webpedidos.util.report.impl.EmissorRelatorio#isRelatorioGerado() // */ // @Override // public boolean isRelatorioGerado() { // return this.relatorioGerado; // } // // } // // Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/impl/RelatorioPedidosEmitidos.java // public final class RelatorioPedidosEmitidos extends RelatorioPedidos { // public RelatorioPedidosEmitidos(Date dataInicio, Date dataFim) { // super(dataInicio, dataFim, RelatorioUtils.localizaRelatorio("relatorio_pedidos_emitidos")); // } // }
import java.io.IOException; import java.io.Serializable; import java.util.Calendar; import java.util.Date; import javax.enterprise.context.RequestScoped; import javax.faces.application.FacesMessage; import javax.faces.context.FacesContext; import javax.inject.Inject; import javax.inject.Named; import javax.servlet.http.HttpServletResponse; import javax.validation.constraints.NotNull; import javax.validation.constraints.Past; import org.joda.time.Days; import org.joda.time.LocalDate; import com.github.marcelothebuilder.webpedidos.util.report.EmissorRelatorio; import com.github.marcelothebuilder.webpedidos.util.report.ExecutorRelatorio; import com.github.marcelothebuilder.webpedidos.util.report.Relatorio; import com.github.marcelothebuilder.webpedidos.util.report.impl.EmissorRelatorioServlet; import com.github.marcelothebuilder.webpedidos.util.report.impl.RelatorioPedidosEmitidos;
Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(1L); return cal.getTime(); } /** * Valida as informações informadas pelo usuário, e caso estejam corretas, * emite a stream do relatório gerado para o client, caso contrário, * fornecem uma mensagem de erro. * * @throws IOException */ public void emitir() { if (this.getDataInicio().after(getDataFim())) { String message = "A data de início deve ser maior que a data fim."; FacesMessage fMessage = new FacesMessage(FacesMessage.SEVERITY_WARN, message, message); fContext.addMessage(null, fMessage); return; } int diasBetween = getIntervaloDias(this.getDataInicio(), this.getDataFim()); if (diasBetween > 180) { String message = "Não é possível emitir um relatório para mais que 180 dias."; FacesMessage fMessage = new FacesMessage(FacesMessage.SEVERITY_WARN, message, message); fContext.addMessage(null, fMessage); return; }
// Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/EmissorRelatorio.java // public interface EmissorRelatorio { // // void setConnection(Connection connection); // // void emitir() throws IOException, JRException; // // boolean isRelatorioGerado(); // // } // // Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/ExecutorRelatorio.java // public interface ExecutorRelatorio { // // void emite(); // // void setEmissor(EmissorRelatorio emissor); // // } // // Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/Relatorio.java // public interface Relatorio { // // Map<String, Object> getParametros(); // // RelatorioFile getArquivo(); // } // // Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/impl/EmissorRelatorioServlet.java // public final class EmissorRelatorioServlet implements EmissorRelatorio { // private Relatorio relatorio; // private Connection connection; // private HttpServletResponse servletResponse; // private boolean relatorioGerado = false; // // public EmissorRelatorioServlet(Relatorio relatorio, HttpServletResponse servletResponse) { // this.relatorio = relatorio; // this.servletResponse = servletResponse; // } // // public EmissorRelatorioServlet(Relatorio relatorio, HttpServletResponse output, Connection connection) { // this(relatorio, output); // this.connection = connection; // } // // /* (non-Javadoc) // * @see com.github.marcelothebuilder.webpedidos.util.report.impl.EmissorRelatorio#setConnection(java.sql.Connection) // */ // @Override // public void setConnection(Connection connection) { // this.connection = connection; // } // // /* (non-Javadoc) // * @see com.github.marcelothebuilder.webpedidos.util.report.impl.EmissorRelatorio#emitir() // */ // @Override // public void emitir() throws JRException { // try (InputStream relatorioArquivoStream = this.getClass().getResourceAsStream(relatorio.getArquivo().getCaminho())) { // JasperPrint print = JasperFillManager.fillReport(relatorioArquivoStream, relatorio.getParametros(), connection); // this.relatorioGerado = print.getPages().size() > 0; // // if(this.isRelatorioGerado()) { // String attachment = String.format("attachment; filename=\"%s.pdf\"", relatorio.getArquivo().getNome()); // servletResponse.setHeader("Content-Disposition", attachment); // JasperExportManager.exportReportToPdfStream(print, servletResponse.getOutputStream()); // } // } catch (IOException e) { // throw new RelatorioNaoExisteException(relatorio, e); // } // } // // /* (non-Javadoc) // * @see com.github.marcelothebuilder.webpedidos.util.report.impl.EmissorRelatorio#isRelatorioGerado() // */ // @Override // public boolean isRelatorioGerado() { // return this.relatorioGerado; // } // // } // // Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/impl/RelatorioPedidosEmitidos.java // public final class RelatorioPedidosEmitidos extends RelatorioPedidos { // public RelatorioPedidosEmitidos(Date dataInicio, Date dataFim) { // super(dataInicio, dataFim, RelatorioUtils.localizaRelatorio("relatorio_pedidos_emitidos")); // } // } // Path: src/main/java/com/github/marcelothebuilder/webpedidos/controller/RelatorioPedidosEmitidosBean.java import java.io.IOException; import java.io.Serializable; import java.util.Calendar; import java.util.Date; import javax.enterprise.context.RequestScoped; import javax.faces.application.FacesMessage; import javax.faces.context.FacesContext; import javax.inject.Inject; import javax.inject.Named; import javax.servlet.http.HttpServletResponse; import javax.validation.constraints.NotNull; import javax.validation.constraints.Past; import org.joda.time.Days; import org.joda.time.LocalDate; import com.github.marcelothebuilder.webpedidos.util.report.EmissorRelatorio; import com.github.marcelothebuilder.webpedidos.util.report.ExecutorRelatorio; import com.github.marcelothebuilder.webpedidos.util.report.Relatorio; import com.github.marcelothebuilder.webpedidos.util.report.impl.EmissorRelatorioServlet; import com.github.marcelothebuilder.webpedidos.util.report.impl.RelatorioPedidosEmitidos; Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(1L); return cal.getTime(); } /** * Valida as informações informadas pelo usuário, e caso estejam corretas, * emite a stream do relatório gerado para o client, caso contrário, * fornecem uma mensagem de erro. * * @throws IOException */ public void emitir() { if (this.getDataInicio().after(getDataFim())) { String message = "A data de início deve ser maior que a data fim."; FacesMessage fMessage = new FacesMessage(FacesMessage.SEVERITY_WARN, message, message); fContext.addMessage(null, fMessage); return; } int diasBetween = getIntervaloDias(this.getDataInicio(), this.getDataFim()); if (diasBetween > 180) { String message = "Não é possível emitir um relatório para mais que 180 dias."; FacesMessage fMessage = new FacesMessage(FacesMessage.SEVERITY_WARN, message, message); fContext.addMessage(null, fMessage); return; }
Relatorio relatorioPedidos = new RelatorioPedidosEmitidos(getDataInicio(), getDataFim());
marcelothebuilder/webpedidos
src/main/java/com/github/marcelothebuilder/webpedidos/controller/RelatorioPedidosEmitidosBean.java
// Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/EmissorRelatorio.java // public interface EmissorRelatorio { // // void setConnection(Connection connection); // // void emitir() throws IOException, JRException; // // boolean isRelatorioGerado(); // // } // // Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/ExecutorRelatorio.java // public interface ExecutorRelatorio { // // void emite(); // // void setEmissor(EmissorRelatorio emissor); // // } // // Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/Relatorio.java // public interface Relatorio { // // Map<String, Object> getParametros(); // // RelatorioFile getArquivo(); // } // // Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/impl/EmissorRelatorioServlet.java // public final class EmissorRelatorioServlet implements EmissorRelatorio { // private Relatorio relatorio; // private Connection connection; // private HttpServletResponse servletResponse; // private boolean relatorioGerado = false; // // public EmissorRelatorioServlet(Relatorio relatorio, HttpServletResponse servletResponse) { // this.relatorio = relatorio; // this.servletResponse = servletResponse; // } // // public EmissorRelatorioServlet(Relatorio relatorio, HttpServletResponse output, Connection connection) { // this(relatorio, output); // this.connection = connection; // } // // /* (non-Javadoc) // * @see com.github.marcelothebuilder.webpedidos.util.report.impl.EmissorRelatorio#setConnection(java.sql.Connection) // */ // @Override // public void setConnection(Connection connection) { // this.connection = connection; // } // // /* (non-Javadoc) // * @see com.github.marcelothebuilder.webpedidos.util.report.impl.EmissorRelatorio#emitir() // */ // @Override // public void emitir() throws JRException { // try (InputStream relatorioArquivoStream = this.getClass().getResourceAsStream(relatorio.getArquivo().getCaminho())) { // JasperPrint print = JasperFillManager.fillReport(relatorioArquivoStream, relatorio.getParametros(), connection); // this.relatorioGerado = print.getPages().size() > 0; // // if(this.isRelatorioGerado()) { // String attachment = String.format("attachment; filename=\"%s.pdf\"", relatorio.getArquivo().getNome()); // servletResponse.setHeader("Content-Disposition", attachment); // JasperExportManager.exportReportToPdfStream(print, servletResponse.getOutputStream()); // } // } catch (IOException e) { // throw new RelatorioNaoExisteException(relatorio, e); // } // } // // /* (non-Javadoc) // * @see com.github.marcelothebuilder.webpedidos.util.report.impl.EmissorRelatorio#isRelatorioGerado() // */ // @Override // public boolean isRelatorioGerado() { // return this.relatorioGerado; // } // // } // // Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/impl/RelatorioPedidosEmitidos.java // public final class RelatorioPedidosEmitidos extends RelatorioPedidos { // public RelatorioPedidosEmitidos(Date dataInicio, Date dataFim) { // super(dataInicio, dataFim, RelatorioUtils.localizaRelatorio("relatorio_pedidos_emitidos")); // } // }
import java.io.IOException; import java.io.Serializable; import java.util.Calendar; import java.util.Date; import javax.enterprise.context.RequestScoped; import javax.faces.application.FacesMessage; import javax.faces.context.FacesContext; import javax.inject.Inject; import javax.inject.Named; import javax.servlet.http.HttpServletResponse; import javax.validation.constraints.NotNull; import javax.validation.constraints.Past; import org.joda.time.Days; import org.joda.time.LocalDate; import com.github.marcelothebuilder.webpedidos.util.report.EmissorRelatorio; import com.github.marcelothebuilder.webpedidos.util.report.ExecutorRelatorio; import com.github.marcelothebuilder.webpedidos.util.report.Relatorio; import com.github.marcelothebuilder.webpedidos.util.report.impl.EmissorRelatorioServlet; import com.github.marcelothebuilder.webpedidos.util.report.impl.RelatorioPedidosEmitidos;
return cal.getTime(); } /** * Valida as informações informadas pelo usuário, e caso estejam corretas, * emite a stream do relatório gerado para o client, caso contrário, * fornecem uma mensagem de erro. * * @throws IOException */ public void emitir() { if (this.getDataInicio().after(getDataFim())) { String message = "A data de início deve ser maior que a data fim."; FacesMessage fMessage = new FacesMessage(FacesMessage.SEVERITY_WARN, message, message); fContext.addMessage(null, fMessage); return; } int diasBetween = getIntervaloDias(this.getDataInicio(), this.getDataFim()); if (diasBetween > 180) { String message = "Não é possível emitir um relatório para mais que 180 dias."; FacesMessage fMessage = new FacesMessage(FacesMessage.SEVERITY_WARN, message, message); fContext.addMessage(null, fMessage); return; } Relatorio relatorioPedidos = new RelatorioPedidosEmitidos(getDataInicio(), getDataFim());
// Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/EmissorRelatorio.java // public interface EmissorRelatorio { // // void setConnection(Connection connection); // // void emitir() throws IOException, JRException; // // boolean isRelatorioGerado(); // // } // // Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/ExecutorRelatorio.java // public interface ExecutorRelatorio { // // void emite(); // // void setEmissor(EmissorRelatorio emissor); // // } // // Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/Relatorio.java // public interface Relatorio { // // Map<String, Object> getParametros(); // // RelatorioFile getArquivo(); // } // // Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/impl/EmissorRelatorioServlet.java // public final class EmissorRelatorioServlet implements EmissorRelatorio { // private Relatorio relatorio; // private Connection connection; // private HttpServletResponse servletResponse; // private boolean relatorioGerado = false; // // public EmissorRelatorioServlet(Relatorio relatorio, HttpServletResponse servletResponse) { // this.relatorio = relatorio; // this.servletResponse = servletResponse; // } // // public EmissorRelatorioServlet(Relatorio relatorio, HttpServletResponse output, Connection connection) { // this(relatorio, output); // this.connection = connection; // } // // /* (non-Javadoc) // * @see com.github.marcelothebuilder.webpedidos.util.report.impl.EmissorRelatorio#setConnection(java.sql.Connection) // */ // @Override // public void setConnection(Connection connection) { // this.connection = connection; // } // // /* (non-Javadoc) // * @see com.github.marcelothebuilder.webpedidos.util.report.impl.EmissorRelatorio#emitir() // */ // @Override // public void emitir() throws JRException { // try (InputStream relatorioArquivoStream = this.getClass().getResourceAsStream(relatorio.getArquivo().getCaminho())) { // JasperPrint print = JasperFillManager.fillReport(relatorioArquivoStream, relatorio.getParametros(), connection); // this.relatorioGerado = print.getPages().size() > 0; // // if(this.isRelatorioGerado()) { // String attachment = String.format("attachment; filename=\"%s.pdf\"", relatorio.getArquivo().getNome()); // servletResponse.setHeader("Content-Disposition", attachment); // JasperExportManager.exportReportToPdfStream(print, servletResponse.getOutputStream()); // } // } catch (IOException e) { // throw new RelatorioNaoExisteException(relatorio, e); // } // } // // /* (non-Javadoc) // * @see com.github.marcelothebuilder.webpedidos.util.report.impl.EmissorRelatorio#isRelatorioGerado() // */ // @Override // public boolean isRelatorioGerado() { // return this.relatorioGerado; // } // // } // // Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/impl/RelatorioPedidosEmitidos.java // public final class RelatorioPedidosEmitidos extends RelatorioPedidos { // public RelatorioPedidosEmitidos(Date dataInicio, Date dataFim) { // super(dataInicio, dataFim, RelatorioUtils.localizaRelatorio("relatorio_pedidos_emitidos")); // } // } // Path: src/main/java/com/github/marcelothebuilder/webpedidos/controller/RelatorioPedidosEmitidosBean.java import java.io.IOException; import java.io.Serializable; import java.util.Calendar; import java.util.Date; import javax.enterprise.context.RequestScoped; import javax.faces.application.FacesMessage; import javax.faces.context.FacesContext; import javax.inject.Inject; import javax.inject.Named; import javax.servlet.http.HttpServletResponse; import javax.validation.constraints.NotNull; import javax.validation.constraints.Past; import org.joda.time.Days; import org.joda.time.LocalDate; import com.github.marcelothebuilder.webpedidos.util.report.EmissorRelatorio; import com.github.marcelothebuilder.webpedidos.util.report.ExecutorRelatorio; import com.github.marcelothebuilder.webpedidos.util.report.Relatorio; import com.github.marcelothebuilder.webpedidos.util.report.impl.EmissorRelatorioServlet; import com.github.marcelothebuilder.webpedidos.util.report.impl.RelatorioPedidosEmitidos; return cal.getTime(); } /** * Valida as informações informadas pelo usuário, e caso estejam corretas, * emite a stream do relatório gerado para o client, caso contrário, * fornecem uma mensagem de erro. * * @throws IOException */ public void emitir() { if (this.getDataInicio().after(getDataFim())) { String message = "A data de início deve ser maior que a data fim."; FacesMessage fMessage = new FacesMessage(FacesMessage.SEVERITY_WARN, message, message); fContext.addMessage(null, fMessage); return; } int diasBetween = getIntervaloDias(this.getDataInicio(), this.getDataFim()); if (diasBetween > 180) { String message = "Não é possível emitir um relatório para mais que 180 dias."; FacesMessage fMessage = new FacesMessage(FacesMessage.SEVERITY_WARN, message, message); fContext.addMessage(null, fMessage); return; } Relatorio relatorioPedidos = new RelatorioPedidosEmitidos(getDataInicio(), getDataFim());
EmissorRelatorio emissor = new EmissorRelatorioServlet(relatorioPedidos, response);
marcelothebuilder/webpedidos
src/main/java/com/github/marcelothebuilder/webpedidos/controller/RelatorioPedidosEmitidosBean.java
// Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/EmissorRelatorio.java // public interface EmissorRelatorio { // // void setConnection(Connection connection); // // void emitir() throws IOException, JRException; // // boolean isRelatorioGerado(); // // } // // Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/ExecutorRelatorio.java // public interface ExecutorRelatorio { // // void emite(); // // void setEmissor(EmissorRelatorio emissor); // // } // // Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/Relatorio.java // public interface Relatorio { // // Map<String, Object> getParametros(); // // RelatorioFile getArquivo(); // } // // Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/impl/EmissorRelatorioServlet.java // public final class EmissorRelatorioServlet implements EmissorRelatorio { // private Relatorio relatorio; // private Connection connection; // private HttpServletResponse servletResponse; // private boolean relatorioGerado = false; // // public EmissorRelatorioServlet(Relatorio relatorio, HttpServletResponse servletResponse) { // this.relatorio = relatorio; // this.servletResponse = servletResponse; // } // // public EmissorRelatorioServlet(Relatorio relatorio, HttpServletResponse output, Connection connection) { // this(relatorio, output); // this.connection = connection; // } // // /* (non-Javadoc) // * @see com.github.marcelothebuilder.webpedidos.util.report.impl.EmissorRelatorio#setConnection(java.sql.Connection) // */ // @Override // public void setConnection(Connection connection) { // this.connection = connection; // } // // /* (non-Javadoc) // * @see com.github.marcelothebuilder.webpedidos.util.report.impl.EmissorRelatorio#emitir() // */ // @Override // public void emitir() throws JRException { // try (InputStream relatorioArquivoStream = this.getClass().getResourceAsStream(relatorio.getArquivo().getCaminho())) { // JasperPrint print = JasperFillManager.fillReport(relatorioArquivoStream, relatorio.getParametros(), connection); // this.relatorioGerado = print.getPages().size() > 0; // // if(this.isRelatorioGerado()) { // String attachment = String.format("attachment; filename=\"%s.pdf\"", relatorio.getArquivo().getNome()); // servletResponse.setHeader("Content-Disposition", attachment); // JasperExportManager.exportReportToPdfStream(print, servletResponse.getOutputStream()); // } // } catch (IOException e) { // throw new RelatorioNaoExisteException(relatorio, e); // } // } // // /* (non-Javadoc) // * @see com.github.marcelothebuilder.webpedidos.util.report.impl.EmissorRelatorio#isRelatorioGerado() // */ // @Override // public boolean isRelatorioGerado() { // return this.relatorioGerado; // } // // } // // Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/impl/RelatorioPedidosEmitidos.java // public final class RelatorioPedidosEmitidos extends RelatorioPedidos { // public RelatorioPedidosEmitidos(Date dataInicio, Date dataFim) { // super(dataInicio, dataFim, RelatorioUtils.localizaRelatorio("relatorio_pedidos_emitidos")); // } // }
import java.io.IOException; import java.io.Serializable; import java.util.Calendar; import java.util.Date; import javax.enterprise.context.RequestScoped; import javax.faces.application.FacesMessage; import javax.faces.context.FacesContext; import javax.inject.Inject; import javax.inject.Named; import javax.servlet.http.HttpServletResponse; import javax.validation.constraints.NotNull; import javax.validation.constraints.Past; import org.joda.time.Days; import org.joda.time.LocalDate; import com.github.marcelothebuilder.webpedidos.util.report.EmissorRelatorio; import com.github.marcelothebuilder.webpedidos.util.report.ExecutorRelatorio; import com.github.marcelothebuilder.webpedidos.util.report.Relatorio; import com.github.marcelothebuilder.webpedidos.util.report.impl.EmissorRelatorioServlet; import com.github.marcelothebuilder.webpedidos.util.report.impl.RelatorioPedidosEmitidos;
return cal.getTime(); } /** * Valida as informações informadas pelo usuário, e caso estejam corretas, * emite a stream do relatório gerado para o client, caso contrário, * fornecem uma mensagem de erro. * * @throws IOException */ public void emitir() { if (this.getDataInicio().after(getDataFim())) { String message = "A data de início deve ser maior que a data fim."; FacesMessage fMessage = new FacesMessage(FacesMessage.SEVERITY_WARN, message, message); fContext.addMessage(null, fMessage); return; } int diasBetween = getIntervaloDias(this.getDataInicio(), this.getDataFim()); if (diasBetween > 180) { String message = "Não é possível emitir um relatório para mais que 180 dias."; FacesMessage fMessage = new FacesMessage(FacesMessage.SEVERITY_WARN, message, message); fContext.addMessage(null, fMessage); return; } Relatorio relatorioPedidos = new RelatorioPedidosEmitidos(getDataInicio(), getDataFim());
// Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/EmissorRelatorio.java // public interface EmissorRelatorio { // // void setConnection(Connection connection); // // void emitir() throws IOException, JRException; // // boolean isRelatorioGerado(); // // } // // Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/ExecutorRelatorio.java // public interface ExecutorRelatorio { // // void emite(); // // void setEmissor(EmissorRelatorio emissor); // // } // // Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/Relatorio.java // public interface Relatorio { // // Map<String, Object> getParametros(); // // RelatorioFile getArquivo(); // } // // Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/impl/EmissorRelatorioServlet.java // public final class EmissorRelatorioServlet implements EmissorRelatorio { // private Relatorio relatorio; // private Connection connection; // private HttpServletResponse servletResponse; // private boolean relatorioGerado = false; // // public EmissorRelatorioServlet(Relatorio relatorio, HttpServletResponse servletResponse) { // this.relatorio = relatorio; // this.servletResponse = servletResponse; // } // // public EmissorRelatorioServlet(Relatorio relatorio, HttpServletResponse output, Connection connection) { // this(relatorio, output); // this.connection = connection; // } // // /* (non-Javadoc) // * @see com.github.marcelothebuilder.webpedidos.util.report.impl.EmissorRelatorio#setConnection(java.sql.Connection) // */ // @Override // public void setConnection(Connection connection) { // this.connection = connection; // } // // /* (non-Javadoc) // * @see com.github.marcelothebuilder.webpedidos.util.report.impl.EmissorRelatorio#emitir() // */ // @Override // public void emitir() throws JRException { // try (InputStream relatorioArquivoStream = this.getClass().getResourceAsStream(relatorio.getArquivo().getCaminho())) { // JasperPrint print = JasperFillManager.fillReport(relatorioArquivoStream, relatorio.getParametros(), connection); // this.relatorioGerado = print.getPages().size() > 0; // // if(this.isRelatorioGerado()) { // String attachment = String.format("attachment; filename=\"%s.pdf\"", relatorio.getArquivo().getNome()); // servletResponse.setHeader("Content-Disposition", attachment); // JasperExportManager.exportReportToPdfStream(print, servletResponse.getOutputStream()); // } // } catch (IOException e) { // throw new RelatorioNaoExisteException(relatorio, e); // } // } // // /* (non-Javadoc) // * @see com.github.marcelothebuilder.webpedidos.util.report.impl.EmissorRelatorio#isRelatorioGerado() // */ // @Override // public boolean isRelatorioGerado() { // return this.relatorioGerado; // } // // } // // Path: src/main/java/com/github/marcelothebuilder/webpedidos/util/report/impl/RelatorioPedidosEmitidos.java // public final class RelatorioPedidosEmitidos extends RelatorioPedidos { // public RelatorioPedidosEmitidos(Date dataInicio, Date dataFim) { // super(dataInicio, dataFim, RelatorioUtils.localizaRelatorio("relatorio_pedidos_emitidos")); // } // } // Path: src/main/java/com/github/marcelothebuilder/webpedidos/controller/RelatorioPedidosEmitidosBean.java import java.io.IOException; import java.io.Serializable; import java.util.Calendar; import java.util.Date; import javax.enterprise.context.RequestScoped; import javax.faces.application.FacesMessage; import javax.faces.context.FacesContext; import javax.inject.Inject; import javax.inject.Named; import javax.servlet.http.HttpServletResponse; import javax.validation.constraints.NotNull; import javax.validation.constraints.Past; import org.joda.time.Days; import org.joda.time.LocalDate; import com.github.marcelothebuilder.webpedidos.util.report.EmissorRelatorio; import com.github.marcelothebuilder.webpedidos.util.report.ExecutorRelatorio; import com.github.marcelothebuilder.webpedidos.util.report.Relatorio; import com.github.marcelothebuilder.webpedidos.util.report.impl.EmissorRelatorioServlet; import com.github.marcelothebuilder.webpedidos.util.report.impl.RelatorioPedidosEmitidos; return cal.getTime(); } /** * Valida as informações informadas pelo usuário, e caso estejam corretas, * emite a stream do relatório gerado para o client, caso contrário, * fornecem uma mensagem de erro. * * @throws IOException */ public void emitir() { if (this.getDataInicio().after(getDataFim())) { String message = "A data de início deve ser maior que a data fim."; FacesMessage fMessage = new FacesMessage(FacesMessage.SEVERITY_WARN, message, message); fContext.addMessage(null, fMessage); return; } int diasBetween = getIntervaloDias(this.getDataInicio(), this.getDataFim()); if (diasBetween > 180) { String message = "Não é possível emitir um relatório para mais que 180 dias."; FacesMessage fMessage = new FacesMessage(FacesMessage.SEVERITY_WARN, message, message); fContext.addMessage(null, fMessage); return; } Relatorio relatorioPedidos = new RelatorioPedidosEmitidos(getDataInicio(), getDataFim());
EmissorRelatorio emissor = new EmissorRelatorioServlet(relatorioPedidos, response);
marcelothebuilder/webpedidos
src/main/java/com/github/marcelothebuilder/webpedidos/model/pedido/ItemPedido.java
// Path: src/main/java/com/github/marcelothebuilder/webpedidos/model/produto/Produto.java // @Entity // @Table(name = "produto", uniqueConstraints = { @UniqueConstraint(name = "uk_sku", columnNames = { "sku" }) }) // public class Produto implements Serializable { // private Long codigo; // private String nome; // private String sku; // private BigDecimal valorUnitario = BigDecimal.ZERO; // private Integer quantidadeEstoque; // private Categoria categoria; // private static final long serialVersionUID = 1L; // // public Produto() { // super(); // } // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // public Long getCodigo() { // return this.codigo; // } // // public void setCodigo(Long codigo) { // this.codigo = codigo; // } // // @NotBlank // @Size(max = 80) // @Column(nullable = false, length = 128) // public String getNome() { // return this.nome; // } // // public void setNome(String nome) { // this.nome = nome; // } // // @NotBlank // @Sku // @Column(nullable = false, length = 20) // // @Column(nullable = false, length = 20, unique = true) // public String getSku() { // return this.sku; // } // // public void setSku(String sku) { // this.sku = sku == null ? null : sku.toUpperCase(); // } // // @NotNull // @Column(name = "valor_unitario", nullable = false, precision = 10, scale = 2) // public BigDecimal getValorUnitario() { // return this.valorUnitario; // } // // public void setValorUnitario(BigDecimal valorUnitario) { // this.valorUnitario = valorUnitario; // } // // @NotNull // @Min(0) // @Max(9999) // @Column(name = "quantidade_estoque", nullable = false) // public Integer getQuantidadeEstoque() { // return this.quantidadeEstoque; // } // // public void setQuantidadeEstoque(Integer quantidadeEstoque) { // this.quantidadeEstoque = quantidadeEstoque; // } // // @NotNull // @ManyToOne(cascade = CascadeType.PERSIST, optional = false) // @JoinColumn(name = "categoria_id", nullable = false, foreignKey = @ForeignKey(name = "fk_produto_to_categoria")) // public Categoria getCategoria() { // return categoria; // } // // public void setCategoria(Categoria categoria) { // this.categoria = categoria; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + ((codigo == null) ? 0 : codigo.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (!(obj instanceof Produto)) // return false; // Produto other = (Produto) obj; // if (codigo == null) { // if (other.codigo != null) // return false; // } else if (!codigo.equals(other.codigo)) // return false; // return true; // } // // @Override // public String toString() { // return String.format("[%s] %s", getSku(), getNome()); // } // // public void baixarEstoque(Integer quantidade) { // int novaQuantidade = this.getQuantidadeEstoque() - quantidade; // if (novaQuantidade < 0) { // String exceptionMessage = String.format("Não há disponibilidade no estoque de %d itens do produto %s - %s", // quantidade, this.getSku(), this.getNome()); // throw new NegocioException(exceptionMessage); // } // this.setQuantidadeEstoque(novaQuantidade); // } // // public void adicionarEstoque(Integer quantidade) { // Integer novaQuantidadeEstoque = this.getQuantidadeEstoque() + quantidade; // this.setQuantidadeEstoque(novaQuantidadeEstoque); // } // // }
import java.io.Serializable; import java.math.BigDecimal; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.ForeignKey; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.Table; import javax.persistence.Transient; import com.github.marcelothebuilder.webpedidos.model.produto.Produto;
package com.github.marcelothebuilder.webpedidos.model.pedido; /** * Entity implementation class for Entity: ItemPedido * */ @Entity @Table(name = "item_pedido") public class ItemPedido implements Serializable { private Integer codigo; private Integer quantidade = 1; private BigDecimal valorUnitario = BigDecimal.ZERO;
// Path: src/main/java/com/github/marcelothebuilder/webpedidos/model/produto/Produto.java // @Entity // @Table(name = "produto", uniqueConstraints = { @UniqueConstraint(name = "uk_sku", columnNames = { "sku" }) }) // public class Produto implements Serializable { // private Long codigo; // private String nome; // private String sku; // private BigDecimal valorUnitario = BigDecimal.ZERO; // private Integer quantidadeEstoque; // private Categoria categoria; // private static final long serialVersionUID = 1L; // // public Produto() { // super(); // } // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // public Long getCodigo() { // return this.codigo; // } // // public void setCodigo(Long codigo) { // this.codigo = codigo; // } // // @NotBlank // @Size(max = 80) // @Column(nullable = false, length = 128) // public String getNome() { // return this.nome; // } // // public void setNome(String nome) { // this.nome = nome; // } // // @NotBlank // @Sku // @Column(nullable = false, length = 20) // // @Column(nullable = false, length = 20, unique = true) // public String getSku() { // return this.sku; // } // // public void setSku(String sku) { // this.sku = sku == null ? null : sku.toUpperCase(); // } // // @NotNull // @Column(name = "valor_unitario", nullable = false, precision = 10, scale = 2) // public BigDecimal getValorUnitario() { // return this.valorUnitario; // } // // public void setValorUnitario(BigDecimal valorUnitario) { // this.valorUnitario = valorUnitario; // } // // @NotNull // @Min(0) // @Max(9999) // @Column(name = "quantidade_estoque", nullable = false) // public Integer getQuantidadeEstoque() { // return this.quantidadeEstoque; // } // // public void setQuantidadeEstoque(Integer quantidadeEstoque) { // this.quantidadeEstoque = quantidadeEstoque; // } // // @NotNull // @ManyToOne(cascade = CascadeType.PERSIST, optional = false) // @JoinColumn(name = "categoria_id", nullable = false, foreignKey = @ForeignKey(name = "fk_produto_to_categoria")) // public Categoria getCategoria() { // return categoria; // } // // public void setCategoria(Categoria categoria) { // this.categoria = categoria; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + ((codigo == null) ? 0 : codigo.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (!(obj instanceof Produto)) // return false; // Produto other = (Produto) obj; // if (codigo == null) { // if (other.codigo != null) // return false; // } else if (!codigo.equals(other.codigo)) // return false; // return true; // } // // @Override // public String toString() { // return String.format("[%s] %s", getSku(), getNome()); // } // // public void baixarEstoque(Integer quantidade) { // int novaQuantidade = this.getQuantidadeEstoque() - quantidade; // if (novaQuantidade < 0) { // String exceptionMessage = String.format("Não há disponibilidade no estoque de %d itens do produto %s - %s", // quantidade, this.getSku(), this.getNome()); // throw new NegocioException(exceptionMessage); // } // this.setQuantidadeEstoque(novaQuantidade); // } // // public void adicionarEstoque(Integer quantidade) { // Integer novaQuantidadeEstoque = this.getQuantidadeEstoque() + quantidade; // this.setQuantidadeEstoque(novaQuantidadeEstoque); // } // // } // Path: src/main/java/com/github/marcelothebuilder/webpedidos/model/pedido/ItemPedido.java import java.io.Serializable; import java.math.BigDecimal; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.ForeignKey; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.Table; import javax.persistence.Transient; import com.github.marcelothebuilder.webpedidos.model.produto.Produto; package com.github.marcelothebuilder.webpedidos.model.pedido; /** * Entity implementation class for Entity: ItemPedido * */ @Entity @Table(name = "item_pedido") public class ItemPedido implements Serializable { private Integer codigo; private Integer quantidade = 1; private BigDecimal valorUnitario = BigDecimal.ZERO;
private Produto produto;
marcelothebuilder/webpedidos
src/main/java/com/github/marcelothebuilder/webpedidos/repository/Grupos.java
// Path: src/main/java/com/github/marcelothebuilder/webpedidos/model/usuario/Grupo.java // @Entity // @Table(name="grupo") // public class Grupo implements Serializable { // private Integer codigo; // private String nome; // private String descricao; // private static final long serialVersionUID = 1L; // // public Grupo() { // super(); // } // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // public Integer getCodigo() { // return this.codigo; // } // // public void setCodigo(Integer codigo) { // this.codigo = codigo; // } // public String getNome() { // return this.nome; // } // // public void setNome(String nome) { // this.nome = nome; // } // public String getDescricao() { // return this.descricao; // } // // public void setDescricao(String descricao) { // this.descricao = descricao; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + ((codigo == null) ? 0 : codigo.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (!(obj instanceof Grupo)) // return false; // Grupo other = (Grupo) obj; // if (codigo == null) { // if (other.codigo != null) // return false; // } else if (!codigo.equals(other.codigo)) // return false; // return true; // } // // // // }
import java.io.Serializable; import java.util.HashSet; import java.util.Set; import javax.inject.Inject; import javax.persistence.EntityManager; import javax.persistence.TypedQuery; import com.github.marcelothebuilder.webpedidos.model.usuario.Grupo;
/** * */ package com.github.marcelothebuilder.webpedidos.repository; /** * @author Marcelo Paixao Resende * */ public class Grupos implements Serializable { private static final long serialVersionUID = 1L; private @Inject EntityManager manager;
// Path: src/main/java/com/github/marcelothebuilder/webpedidos/model/usuario/Grupo.java // @Entity // @Table(name="grupo") // public class Grupo implements Serializable { // private Integer codigo; // private String nome; // private String descricao; // private static final long serialVersionUID = 1L; // // public Grupo() { // super(); // } // // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // public Integer getCodigo() { // return this.codigo; // } // // public void setCodigo(Integer codigo) { // this.codigo = codigo; // } // public String getNome() { // return this.nome; // } // // public void setNome(String nome) { // this.nome = nome; // } // public String getDescricao() { // return this.descricao; // } // // public void setDescricao(String descricao) { // this.descricao = descricao; // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + ((codigo == null) ? 0 : codigo.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if (this == obj) // return true; // if (obj == null) // return false; // if (!(obj instanceof Grupo)) // return false; // Grupo other = (Grupo) obj; // if (codigo == null) { // if (other.codigo != null) // return false; // } else if (!codigo.equals(other.codigo)) // return false; // return true; // } // // // // } // Path: src/main/java/com/github/marcelothebuilder/webpedidos/repository/Grupos.java import java.io.Serializable; import java.util.HashSet; import java.util.Set; import javax.inject.Inject; import javax.persistence.EntityManager; import javax.persistence.TypedQuery; import com.github.marcelothebuilder.webpedidos.model.usuario.Grupo; /** * */ package com.github.marcelothebuilder.webpedidos.repository; /** * @author Marcelo Paixao Resende * */ public class Grupos implements Serializable { private static final long serialVersionUID = 1L; private @Inject EntityManager manager;
public Set<Grupo> todos() {